chore: improve message fetching

This commit is contained in:
2025-08-03 20:34:35 +07:00
parent c8c5a6668d
commit 493223276c
13 changed files with 231 additions and 117 deletions

View File

@@ -20,7 +20,10 @@ pub(crate) const HOURS_IN_DAY: i64 = 24;
pub(crate) const DAYS_IN_MONTH: i64 = 30;
#[derive(Debug, Clone)]
pub struct Incoming(pub Message);
pub enum RoomSignal {
NewMessage(Message),
Refresh,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SendError {
@@ -69,7 +72,7 @@ impl PartialEq for Room {
impl Eq for Room {}
impl EventEmitter<Incoming> for Room {}
impl EventEmitter<RoomSignal> for Room {}
impl Room {
pub fn new(event: &Event) -> Self {
@@ -451,10 +454,16 @@ impl Room {
.mentions(mentions)
.build()
{
cx.emit(Incoming(message));
cx.emit(RoomSignal::NewMessage(message));
}
}
/// Emits a signal to refresh the current room's messages.
pub fn emit_refresh(&mut self, cx: &mut Context<Self>) {
cx.emit(RoomSignal::Refresh);
log::info!("refresh room: {}", self.id);
}
/// Creates a temporary message for optimistic updates
///
/// This constructs an unsigned message with the current user as the author,