diff --git a/src/ephemeral.rs b/src/ephemeral.rs index 46922a0e4..c9ea6891b 100644 --- a/src/ephemeral.rs +++ b/src/ephemeral.rs @@ -63,6 +63,7 @@ //! ephemeral message timers or global `delete_server_after` setting. use std::cmp::max; +use std::collections::BTreeSet; use std::convert::{TryFrom, TryInto}; use std::num::ParseIntError; use std::str::FromStr; @@ -455,11 +456,16 @@ pub(crate) async fn delete_expired_messages(context: &Context, now: i64) -> Resu }) .await?; + let mut modified_chat_ids = BTreeSet::new(); + for (chat_id, msg_id) in msgs_changed { - context.emit_event(EventType::MsgDeleted { chat_id, msg_id }) + context.emit_event(EventType::MsgDeleted { chat_id, msg_id }); + modified_chat_ids.insert(chat_id); } - context.emit_msgs_changed_without_ids(); + for modified_chat_id in modified_chat_ids { + context.emit_msgs_changed(modified_chat_id, MsgId::new(0)); + } for msg_id in webxdc_deleted { context.emit_event(EventType::WebxdcInstanceDeleted { msg_id }); diff --git a/src/message.rs b/src/message.rs index 563f18890..93ef2cad2 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1421,6 +1421,8 @@ pub async fn get_mime_headers(context: &Context, msg_id: MsgId) -> Result Result<()> { + let mut modified_chat_ids = BTreeSet::new(); + for &msg_id in msg_ids { let msg = Message::load_from_db(context, msg_id).await?; if msg.location_id > 0 { @@ -1440,6 +1442,8 @@ pub async fn delete_msgs(context: &Context, msg_ids: &[MsgId]) -> Result<()> { context.emit_event(EventType::WebxdcInstanceDeleted { msg_id }); } + modified_chat_ids.insert(msg.chat_id); + let target = context.get_delete_msgs_target().await?; context .sql @@ -1463,9 +1467,11 @@ pub async fn delete_msgs(context: &Context, msg_ids: &[MsgId]) -> Result<()> { } } - if !msg_ids.is_empty() { - context.emit_msgs_changed_without_ids(); + for modified_chat_id in modified_chat_ids { + context.emit_msgs_changed(modified_chat_id, MsgId::new(0)); + } + if !msg_ids.is_empty() { // Run housekeeping to delete unused blobs. context.set_config(Config::LastHousekeeping, None).await?; }