diff --git a/src/chat.rs b/src/chat.rs index 548943036..bc5a1a77c 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1,7 +1,7 @@ //! # Chat module. use std::cmp; -use std::collections::{BTreeSet, HashMap, HashSet}; +use std::collections::{BTreeSet, HashMap}; use std::fmt; use std::io::Cursor; use std::marker::Sync; @@ -3774,7 +3774,7 @@ pub(crate) async fn update_chat_contacts_table( context: &Context, timestamp: i64, id: ChatId, - contacts: &HashSet, + contacts: &BTreeSet, ) -> Result<()> { context .sql @@ -5033,7 +5033,7 @@ async fn set_contacts_by_addrs(context: &Context, id: ChatId, addrs: &[String]) chat.typ == Chattype::OutBroadcast, "{id} is not a broadcast list", ); - let mut contacts = HashSet::new(); + let mut contacts = BTreeSet::new(); for addr in addrs { let contact_addr = ContactAddress::new(addr)?; let contact = Contact::add_or_lookup(context, "", &contact_addr, Origin::Hidden) @@ -5041,7 +5041,7 @@ async fn set_contacts_by_addrs(context: &Context, id: ChatId, addrs: &[String]) .0; contacts.insert(contact); } - let contacts_old = HashSet::::from_iter(get_chat_contacts(context, id).await?); + let contacts_old = BTreeSet::::from_iter(get_chat_contacts(context, id).await?); if contacts == contacts_old { return Ok(()); } diff --git a/src/message.rs b/src/message.rs index 0ae7591cc..b5a9caf4a 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,7 +1,6 @@ //! # Messages and their identifiers. use std::collections::BTreeSet; -use std::collections::HashSet; use std::path::{Path, PathBuf}; use std::str; @@ -1693,7 +1692,7 @@ pub(crate) async fn delete_msg_locally(context: &Context, msg: &Message) -> Resu pub(crate) async fn delete_msgs_locally_done( context: &Context, msg_ids: &[MsgId], - modified_chat_ids: HashSet, + modified_chat_ids: BTreeSet, ) -> Result<()> { for modified_chat_id in modified_chat_ids { context.emit_msgs_changed_without_msg_id(modified_chat_id); @@ -1723,7 +1722,7 @@ pub async fn delete_msgs_ex( msg_ids: &[MsgId], delete_for_all: bool, ) -> Result<()> { - let mut modified_chat_ids = HashSet::new(); + let mut modified_chat_ids = BTreeSet::new(); let mut deleted_rfc724_mid = Vec::new(); let mut res = Ok(()); diff --git a/src/receive_imf.rs b/src/receive_imf.rs index efce9d9eb..79ee1efdb 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -1,7 +1,7 @@ //! Internet Message Format reception pipeline. use std::cmp; -use std::collections::{BTreeMap, BTreeSet, HashSet}; +use std::collections::{BTreeMap, BTreeSet}; use std::iter; use std::sync::LazyLock; @@ -1927,7 +1927,7 @@ async fn add_parts( && chat_id.get_ephemeral_timer(context).await? != ephemeral_timer { let chat_contacts = - HashSet::::from_iter(chat::get_chat_contacts(context, chat_id).await?); + BTreeSet::::from_iter(chat::get_chat_contacts(context, chat_id).await?); let is_from_in_chat = !chat_contacts.contains(&ContactId::SELF) || chat_contacts.contains(&from_id); @@ -2462,7 +2462,7 @@ async fn handle_edit_delete( // See `message::delete_msgs_ex()`, unlike edit requests, DC doesn't send unencrypted // deletion requests, so there's no need to support them. if part.param.get_bool(Param::GuaranteeE2ee).unwrap_or(false) { - let mut modified_chat_ids = HashSet::new(); + let mut modified_chat_ids = BTreeSet::new(); let mut msg_ids = Vec::new(); let rfc724_mid_vec: Vec<&str> = rfc724_mid_list.split_whitespace().collect(); @@ -3094,7 +3094,7 @@ async fn apply_group_changes( let mut better_msg = None; let mut silent = false; let chat_contacts = - HashSet::::from_iter(chat::get_chat_contacts(context, chat.id).await?); + BTreeSet::::from_iter(chat::get_chat_contacts(context, chat.id).await?); let is_from_in_chat = !chat_contacts.contains(&ContactId::SELF) || chat_contacts.contains(&from_id); @@ -3172,8 +3172,8 @@ async fn apply_group_changes( && chat.member_list_is_stale(context).await? { info!(context, "Member list is stale."); - let mut new_members: HashSet = - HashSet::from_iter(to_ids_flat.iter().copied()); + let mut new_members: BTreeSet = + BTreeSet::from_iter(to_ids_flat.iter().copied()); new_members.insert(ContactId::SELF); if !from_id.is_special() { new_members.insert(from_id); @@ -3217,7 +3217,7 @@ async fn apply_group_changes( ) .await?; } else { - let mut new_members: HashSet; + let mut new_members: BTreeSet; // True if a Delta Chat client has explicitly and really added our primary address to an // already existing group. let self_added = @@ -3228,7 +3228,7 @@ async fn apply_group_changes( false }; if self_added { - new_members = HashSet::from_iter(to_ids_flat.iter().copied()); + new_members = BTreeSet::from_iter(to_ids_flat.iter().copied()); new_members.insert(ContactId::SELF); if !from_id.is_special() && from_is_key_contact != chat.grpid.is_empty() { new_members.insert(from_id); @@ -3279,7 +3279,7 @@ async fn apply_group_changes( .await?; } - let new_chat_contacts = HashSet::::from_iter( + let new_chat_contacts = BTreeSet::::from_iter( chat::get_chat_contacts(context, chat.id) .await? .iter() @@ -3287,11 +3287,11 @@ async fn apply_group_changes( ); // These are for adding info messages about implicit membership changes. - let mut added_ids: HashSet = new_chat_contacts + let mut added_ids: BTreeSet = new_chat_contacts .difference(&chat_contacts) .copied() .collect(); - let mut removed_ids: HashSet = chat_contacts + let mut removed_ids: BTreeSet = chat_contacts .difference(&new_chat_contacts) .copied() .collect(); @@ -3513,8 +3513,8 @@ async fn apply_chat_name_avatar_and_description_changes( #[expect(clippy::arithmetic_side_effects)] async fn group_changes_msgs( context: &Context, - added_ids: &HashSet, - removed_ids: &HashSet, + added_ids: &BTreeSet, + removed_ids: &BTreeSet, chat_id: ChatId, ) -> Result)>> { let mut group_changes_msgs: Vec<(String, SystemMessage, Option)> = Vec::new(); diff --git a/src/sync.rs b/src/sync.rs index 3e87bb05e..8b050456d 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -19,7 +19,7 @@ use crate::token::Namespace; use crate::tools::time; use crate::transport::{ConfiguredLoginParamJson, sync_transports}; use crate::{message, stock_str, token}; -use std::collections::HashSet; +use std::collections::BTreeSet; /// Whether to send device sync messages. Aimed for usage in the internal API. #[derive(Debug, PartialEq)] @@ -383,7 +383,7 @@ impl Context { } async fn sync_message_deletion(&self, msgs: &Vec) -> Result<()> { - let mut modified_chat_ids = HashSet::new(); + let mut modified_chat_ids = BTreeSet::new(); let mut msg_ids = Vec::new(); for rfc724_mid in msgs { if let Some(msg_id) = message::rfc724_mid_exists(self, rfc724_mid).await? {