mirror of
https://github.com/chatmail/core.git
synced 2026-04-28 10:56:29 +03:00
fix: add ChatlistItemChanged event to
`on_archived_chats_maybe_noticed` Also fixes duplicated events when marking archived link as noticed.
This commit is contained in:
@@ -3316,7 +3316,10 @@ pub async fn marknoticed_chat(context: &Context, chat_id: ChatId) -> Result<()>
|
||||
|
||||
context.emit_event(EventType::MsgsNoticed(chat_id));
|
||||
chatlist_events::emit_chatlist_item_changed(context, chat_id);
|
||||
context.on_archived_chats_maybe_noticed();
|
||||
if !chat_id.is_archived_link() {
|
||||
// prevents event duplication when marking all archived chats as noticed
|
||||
context.on_archived_chats_maybe_noticed();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -5110,12 +5113,14 @@ impl Context {
|
||||
}
|
||||
}
|
||||
|
||||
/// Emits the appropriate `MsgsChanged` event. Should be called if the number of unnoticed
|
||||
/// Emits the appropriate `MsgsChanged` and `ChatlistItemChanged` event.
|
||||
/// Should be called if the number of unnoticed
|
||||
/// archived chats could decrease. In general we don't want to make an extra db query to know if
|
||||
/// a noticed chat is archived. Emitting events should be cheap, a false-positive `MsgsChanged`
|
||||
/// is ok.
|
||||
pub(crate) fn on_archived_chats_maybe_noticed(&self) {
|
||||
self.emit_msgs_changed_without_msg_id(DC_CHAT_ID_ARCHIVED_LINK);
|
||||
chatlist_events::emit_chatlist_item_changed(self, DC_CHAT_ID_ARCHIVED_LINK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user