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
Generated
+1
View File
@@ -9363,6 +9363,7 @@ dependencies = [
"chat_ui",
"common",
"community",
"community_ui",
"device",
"gpui-pre",
"instant",
+1
View File
@@ -13,6 +13,7 @@ device = { path = "../device" }
chat = { path = "../chat" }
chat_ui = { path = "../chat_ui" }
community = { path = "../community" }
community_ui = { path = "../community_ui" }
settings = { path = "../settings" }
person = { path = "../person" }
auto_update = { path = "../auto_update" }
+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);
+12 -3
View File
@@ -100,7 +100,12 @@ impl Sidebar {
cx.notify();
}
fn open_community(&mut self, community: Entity<Community>, cx: &mut Context<Self>) {
fn open_community(
&mut self,
community: Entity<Community>,
window: &mut Window,
cx: &mut Context<Self>,
) {
let id = community.read(cx).id().to_hex();
let settings = AppSettings::global(cx);
@@ -108,6 +113,10 @@ impl Sidebar {
settings.record_recent_community(id, cx);
});
CommunityRegistry::global(cx).update(cx, |registry, cx| {
registry.emit_community(&community, window, cx);
});
cx.notify();
}
@@ -392,8 +401,8 @@ fn render_rows(range: Range<usize>, rows: &[SidebarRow], cx: &Context<Sidebar>)
)
.avatar(seed)
.picture(picture)
.on_click(cx.listener(move |this, _event, _window, cx| {
this.open_community(community.clone(), cx);
.on_click(cx.listener(move |this, _event, window, cx| {
this.open_community(community.clone(), window, cx);
}))
.into_any_element()
}