From f730cec29def4f5d29b8e27e6be200b431db1887 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Thu, 20 Mar 2025 15:24:06 +0000 Subject: fix: chat list ordering now concrete, unaffected by unpredictable runtime task order --- src/main.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index ed6ce1b..f79caf3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,7 +62,7 @@ pub struct Macaw { roster: HashMap, users: HashMap, presences: HashMap, - chats: IndexMap, + chats: IndexMap)>, subscription_requests: HashSet, open_chat: Option, new_chat: Option, @@ -394,7 +394,7 @@ impl Macaw { self.chats.shift_remove_entry(&to) { self.chats - .insert_before(0, chat_jid, (chat, message.clone())); + .insert_before(0, chat_jid, (chat, Some(message.clone()))); if let Some(open_chat) = &mut self.open_chat { if open_chat.jid == to { open_chat.update(message_view::Message::Message(message)); @@ -405,7 +405,7 @@ impl Macaw { correspondent: to.clone(), }; let message_history = indexmap! {message.id => message.clone()}; - self.chats.insert_before(0, to, (chat, message)); + self.chats.insert_before(0, to, (chat, Some(message))); } Task::none() } @@ -593,6 +593,8 @@ impl Macaw { } }; for chat in chats { + self.chats + .insert(chat.correspondent.clone(), (chat.clone(), None)); let client = client.clone(); let correspondent = chat.correspondent.clone(); tasks.push(Task::perform( @@ -625,7 +627,7 @@ impl Macaw { // TODO: don't get the entire message history LOL if let Some((_id, message)) = message_history.pop() { self.chats - .insert(chat.correspondent.clone(), (chat, message)); + .insert(chat.correspondent.clone(), (chat, Some(message))); } Task::none() } -- cgit