update ui

This commit is contained in:
2026-09-20 09:53:39 +07:00
parent 3bbdc5ad34
commit 29f3c74d06
4 changed files with 37 additions and 4 deletions
+23 -1
View File
@@ -6,6 +6,7 @@ use anyhow::Error;
use auto_update::AutoUpdater;
use chat::{ChatEvent, ChatRegistry};
use common::download_dir;
use community::{CommunityEvent, CommunityRegistry};
use device::{DeviceEvent, DeviceRegistry};
use gpui::prelude::FluentBuilder;
use gpui::{
@@ -73,12 +74,13 @@ pub struct Workspace {
/// Async tasks
tasks: Vec<Task<Result<(), Error>>>,
/// Event subscriptions
_subscriptions: SmallVec<[Subscription; 6]>,
_subscriptions: SmallVec<[Subscription; 7]>,
}
impl Workspace {
fn new(window: &mut Window, cx: &mut Context<Self>) -> Self {
let chat = ChatRegistry::global(cx);
let communities = CommunityRegistry::global(cx);
let device = DeviceRegistry::global(cx);
let nostr = NostrRegistry::global(cx);
@@ -212,6 +214,26 @@ impl Workspace {
}),
);
subscriptions.push(
// Observe all events emitted by the community registry
cx.subscribe_in(
&communities,
window,
move |this, communities, event, window, cx| {
if let CommunityEvent::Open(id) = event
&& let Some(community) = communities.read(cx).community(id)
{
this.add_panel_to_dock(
community_ui::init(community, window, cx),
DockPlacement::Center,
window,
cx,
);
}
},
),
);
cx.defer_in(window, move |this, window, cx| {
let sidebar = PanelHandle::new(sidebar);