Replace BTreeMap with BTreeSet in markseen_msgs

This commit is contained in:
link2xt
2022-01-02 21:33:54 +00:00
parent f63efc29bf
commit 1f31dd12fc

View File

@@ -1,6 +1,6 @@
//! # Messages and their identifiers. //! # Messages and their identifiers.
use std::collections::BTreeMap; use std::collections::BTreeSet;
use std::convert::TryInto; use std::convert::TryInto;
use anyhow::{ensure, format_err, Context as _, Result}; use anyhow::{ensure, format_err, Context as _, Result};
@@ -1283,7 +1283,7 @@ pub async fn markseen_msgs(context: &Context, msg_ids: Vec<MsgId>) -> Result<()>
}) })
.await?; .await?;
let mut updated_chat_ids = BTreeMap::new(); let mut updated_chat_ids = BTreeSet::new();
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 {
@@ -1305,12 +1305,12 @@ pub async fn markseen_msgs(context: &Context, msg_ids: Vec<MsgId>) -> Result<()>
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_ids.insert(curr_chat_id, true); updated_chat_ids.insert(curr_chat_id);
} }
} }
for updated_chat_id in updated_chat_ids.keys() { for updated_chat_id in updated_chat_ids {
context.emit_event(EventType::MsgsNoticed(*updated_chat_id)); context.emit_event(EventType::MsgsNoticed(updated_chat_id));
} }
Ok(()) Ok(())