This commit is contained in:
2026-04-21 20:30:41 +01:00
parent 6c60013295
commit e8005f3fbf
13 changed files with 234 additions and 97 deletions

View File

@@ -2,7 +2,7 @@ use gpui::prelude::FluentBuilder;
use gpui::{ParentElement, Styled, div};
use crate::component::button::button;
use crate::query::{QueryStatus, read_query, use_query};
use crate::query::{self, QueryStatus, read_query, use_query};
use crate::{
api, app,
component::{
@@ -11,14 +11,17 @@ use crate::{
},
};
pub struct TitleBar {}
pub struct TitleBar {
fetch_user_query: query::Entity<api::user::Fetch>,
}
pub struct RepoSelector {}
impl TitleBar {
pub fn new(cx: &mut gpui::Context<Self>) -> Self {
use_query(api::user::Fetch, cx);
Self {}
Self {
fetch_user_query: use_query(api::user::Fetch, cx),
}
}
}
@@ -29,13 +32,14 @@ impl gpui::Render for TitleBar {
cx: &mut gpui::Context<Self>,
) -> impl gpui::IntoElement {
let g = cx.global::<app::Global>();
let user = read_query(api::user::Fetch, cx);
let user = read_query(&self.fetch_user_query, cx);
let user_avatar = match user {
QueryStatus::Err(api::Error::Unauthenticated) => div()
.absolute()
.right_2p5()
.child(button("login-btn", cx).label("Login")),
QueryStatus::Err(api::Error::Unauthenticated) => div().absolute().right_2p5().child(
button("login-btn", cx)
.leading(font_icon(FontIcon::Github, cx))
.label("Login"),
),
_ => div(),
};