chore: refactor chat registry

This commit is contained in:
2025-02-11 15:01:03 +07:00
parent 76d2c14870
commit 140a16e617
13 changed files with 297 additions and 319 deletions

View File

@@ -1,5 +1,4 @@
use cargo_packager_updater::{check_update, semver::Version, url::Url};
use chat_state::registry::ChatRegistry;
use common::{
constants::{UPDATER_PUBKEY, UPDATER_URL},
profile::NostrProfile,
@@ -217,14 +216,10 @@ impl AppView {
fn on_panel_action(&mut self, action: &AddPanel, window: &mut Window, cx: &mut Context<Self>) {
match &action.panel {
PanelKind::Room(id) => {
if let Some(weak_room) = cx.global::<ChatRegistry>().get_room(id, cx) {
if let Some(room) = weak_room.upgrade() {
let panel = Arc::new(chat::init(&room, window, cx));
self.dock.update(cx, |dock_area, cx| {
dock_area.add_panel(panel, action.position, window, cx);
});
}
if let Ok(panel) = chat::init(id, window, cx) {
self.dock.update(cx, |dock_area, cx| {
dock_area.add_panel(panel, action.position, window, cx);
});
}
}
PanelKind::Profile => {