chore: refactor chat room

This commit is contained in:
2025-02-24 16:18:21 +07:00
parent 3f8c02aef8
commit 1c4806bd92
6 changed files with 185 additions and 246 deletions

View File

@@ -1,4 +1,4 @@
use crate::room::Room;
use crate::room::{IncomingEvent, Room};
use anyhow::anyhow;
use common::{last_seen::LastSeen, utils::room_hash};
use gpui::{App, AppContext, Context, Entity, Global, WeakEntity};
@@ -175,7 +175,7 @@ impl ChatRegistry {
if let Some(last_seen) = Rc::get_mut(&mut this.last_seen) {
*last_seen = LastSeen(event.created_at);
}
this.new_messages.push(event);
cx.emit(IncomingEvent { event });
cx.notify();
});
@@ -184,8 +184,8 @@ impl ChatRegistry {
cx.notify();
} else {
let mut rooms = self.rooms.write().unwrap();
let new_room = Room::new(&event, cx);
let mut rooms = self.rooms.write().unwrap();
rooms.insert(0, new_room);
cx.notify();