From 1f31dd12fc0c1245e6e2c31c3c796f7816a53196 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sun, 2 Jan 2022 21:33:54 +0000 Subject: [PATCH] Replace `BTreeMap` with `BTreeSet` in `markseen_msgs` --- src/message.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/message.rs b/src/message.rs index 898e61969..6514ba444 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,6 +1,6 @@ //! # Messages and their identifiers. -use std::collections::BTreeMap; +use std::collections::BTreeSet; use std::convert::TryInto; use anyhow::{ensure, format_err, Context as _, Result}; @@ -1283,7 +1283,7 @@ pub async fn markseen_msgs(context: &Context, msg_ids: Vec) -> Result<()> }) .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() { if let Err(err) = id.start_ephemeral_timer(context).await { @@ -1305,12 +1305,12 @@ pub async fn markseen_msgs(context: &Context, msg_ids: Vec) -> Result<()> job::Job::new(Action::MarkseenMsgOnImap, id.to_u32(), Params::new(), 0), ) .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() { - context.emit_event(EventType::MsgsNoticed(*updated_chat_id)); + for updated_chat_id in updated_chat_ids { + context.emit_event(EventType::MsgsNoticed(updated_chat_id)); } Ok(())