mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 17:06:35 +03:00
emit multiple events if messages given to dc_markseen_msgs() belong to different chats
This commit is contained in:
@@ -1528,8 +1528,7 @@ void dc_marknoticed_contact (dc_context_t* context, uint32_t co
|
|||||||
* Moreover, if messages belong to a chat with ephemeral messages enabled,
|
* Moreover, if messages belong to a chat with ephemeral messages enabled,
|
||||||
* the ephemeral timer is started for these messages.
|
* the ephemeral timer is started for these messages.
|
||||||
*
|
*
|
||||||
* The given messages are expected to belong to the same chat or to the deaddrop;
|
* One #DC_EVENT_MSGS_NOTICED event is emitted per modified chat.
|
||||||
* only one #DC_EVENT_MSGS_NOTICED event with this chat may be emitted.
|
|
||||||
*
|
*
|
||||||
* @memberof dc_context_t
|
* @memberof dc_context_t
|
||||||
* @param context The context object.
|
* @param context The context object.
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ use crate::mimeparser::{FailureReport, SystemMessage};
|
|||||||
use crate::param::*;
|
use crate::param::*;
|
||||||
use crate::pgp::*;
|
use crate::pgp::*;
|
||||||
use crate::stock::StockMessage;
|
use crate::stock::StockMessage;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
// In practice, the user additionally cuts the string themselves
|
// In practice, the user additionally cuts the string themselves
|
||||||
// pixel-accurate.
|
// pixel-accurate.
|
||||||
@@ -1255,8 +1256,7 @@ pub async fn markseen_msgs(context: &Context, msg_ids: Vec<MsgId>) -> bool {
|
|||||||
.await
|
.await
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
// we expect all messages belong to the same chat or to the deaddrop.
|
let mut updated_chat_ids = BTreeMap::new();
|
||||||
let mut updated_chat_id = ChatId::new(0);
|
|
||||||
|
|
||||||
for (id, curr_chat_id, curr_state, curr_blocked) in msgs.into_iter() {
|
for (id, curr_chat_id, curr_state, curr_blocked) in msgs.into_iter() {
|
||||||
if let Err(err) = id.start_ephemeral_timer(context).await {
|
if let Err(err) = id.start_ephemeral_timer(context).await {
|
||||||
@@ -1277,16 +1277,16 @@ pub async fn markseen_msgs(context: &Context, msg_ids: Vec<MsgId>) -> bool {
|
|||||||
job::Job::new(Action::MarkseenMsgOnImap, id.to_u32(), Params::new(), 0),
|
job::Job::new(Action::MarkseenMsgOnImap, id.to_u32(), Params::new(), 0),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
updated_chat_id = curr_chat_id;
|
updated_chat_ids.insert(curr_chat_id, true);
|
||||||
}
|
}
|
||||||
} else if curr_state == MessageState::InFresh {
|
} else if curr_state == MessageState::InFresh {
|
||||||
update_msg_state(context, id, MessageState::InNoticed).await;
|
update_msg_state(context, id, MessageState::InNoticed).await;
|
||||||
updated_chat_id = ChatId::new(DC_CHAT_ID_DEADDROP);
|
updated_chat_ids.insert(ChatId::new(DC_CHAT_ID_DEADDROP), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !updated_chat_id.is_unset() {
|
for (updated_chat_id, _) in &updated_chat_ids {
|
||||||
context.emit_event(EventType::MsgsNoticed(updated_chat_id));
|
context.emit_event(EventType::MsgsNoticed(*updated_chat_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
true
|
true
|
||||||
|
|||||||
Reference in New Issue
Block a user