update dock
This commit is contained in:
@@ -1,20 +1,18 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use assets::CustomIconName;
|
||||
use dock::{DockArea, DockItem};
|
||||
use gpui::prelude::*;
|
||||
use gpui::{Context, Entity, Render, SharedString, Subscription, Window, div, px};
|
||||
use gpui_component::button::{Button, ButtonVariants};
|
||||
use gpui_component::{ActiveTheme, Root, Sizable, StyledExt, Theme, TitleBar, h_flex, v_flex};
|
||||
use gpui::{Context, Entity, Render, Subscription, Window, div, px};
|
||||
use gpui_component::{Root, StyledExt, Theme};
|
||||
use signed_state::{Backend, BackendEvent};
|
||||
|
||||
use crate::views::SidebarPanel;
|
||||
use crate::views::sidebar::passphrase_dialog;
|
||||
|
||||
/// Root view of the app: title bar, dock area, status bar.
|
||||
/// Root view of the app: dock area (whose center tab bar doubles as the
|
||||
/// window title bar), overlays.
|
||||
pub struct Workspace {
|
||||
dock: Entity<DockArea>,
|
||||
status: SharedString,
|
||||
_subscriptions: Vec<Subscription>,
|
||||
_passphrase_subscription: Subscription,
|
||||
}
|
||||
@@ -40,16 +38,6 @@ impl Workspace {
|
||||
});
|
||||
|
||||
let backend = Backend::global(cx);
|
||||
let connected = backend.read(cx).is_connected();
|
||||
let sync_progress = backend.read(cx).sync_progress();
|
||||
|
||||
let status = if let Some((total, current)) = sync_progress {
|
||||
format!("Syncing repositories... {current}/{total}").into()
|
||||
} else if connected {
|
||||
"Connected".into()
|
||||
} else {
|
||||
"Connecting...".into()
|
||||
};
|
||||
|
||||
let mut subscriptions = vec![];
|
||||
|
||||
@@ -57,19 +45,6 @@ impl Workspace {
|
||||
Theme::sync_system_appearance(Some(window), cx);
|
||||
}));
|
||||
|
||||
subscriptions.push(cx.subscribe(&backend, |this, _backend, event, cx| {
|
||||
match event {
|
||||
BackendEvent::SyncProgress { total, current } => {
|
||||
this.status = format!("Syncing repositories... {current}/{total}").into()
|
||||
}
|
||||
BackendEvent::Synced => this.status = "Connected".into(),
|
||||
BackendEvent::Connected => this.status = "Connected".into(),
|
||||
BackendEvent::Error(error) => this.status = error.clone().into(),
|
||||
_ => return,
|
||||
}
|
||||
cx.notify();
|
||||
}));
|
||||
|
||||
// Ask for the passphrase when the stored identity is NIP-49
|
||||
// encrypted. Subscribed via the window, since opening a dialog
|
||||
// needs one.
|
||||
@@ -98,7 +73,6 @@ impl Workspace {
|
||||
|
||||
Self {
|
||||
dock,
|
||||
status,
|
||||
_subscriptions: subscriptions,
|
||||
_passphrase_subscription: passphrase_subscription,
|
||||
}
|
||||
@@ -111,44 +85,11 @@ impl Render for Workspace {
|
||||
let notification_layer = Root::render_notification_layer(window, cx);
|
||||
|
||||
div()
|
||||
// All `img` elements below (avatars, …) load through the shared
|
||||
// bounded LRU cache instead of the window-global asset cache,
|
||||
// so images can be freed when views close or when the cache is
|
||||
// full.
|
||||
.image_cache(crate::image_cache::global(cx))
|
||||
.id("workspace")
|
||||
.v_flex()
|
||||
.size_full()
|
||||
.child(
|
||||
v_flex()
|
||||
.size_full()
|
||||
// Title Bar
|
||||
.child(
|
||||
TitleBar::new()
|
||||
// Left
|
||||
.child(div())
|
||||
// Right
|
||||
.child(h_flex().px_2().map(|this| {
|
||||
if self.status == "Connected" {
|
||||
this.child(
|
||||
Button::new("relay")
|
||||
.icon(CustomIconName::GlobalOn)
|
||||
.small()
|
||||
.ghost(),
|
||||
)
|
||||
} else {
|
||||
this.child(
|
||||
div()
|
||||
.text_xs()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child(self.status.clone()),
|
||||
)
|
||||
}
|
||||
})),
|
||||
)
|
||||
// Dock Area
|
||||
.child(self.dock.clone()),
|
||||
)
|
||||
.child(self.dock.clone())
|
||||
// Notifications
|
||||
.children(notification_layer)
|
||||
// Modals
|
||||
|
||||
Reference in New Issue
Block a user