aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@bunny.garden>2025-03-20 15:24:06 +0000
committerLibravatar cel 🌸 <cel@bunny.garden>2025-03-20 15:24:06 +0000
commitf730cec29def4f5d29b8e27e6be200b431db1887 (patch)
tree38d82ca8f63fcd2c12f88e79bc3f9febaf9dd8a1
parent0a24d4008c0cbd7bd07816a8f95fda750616c797 (diff)
downloadmacaw-f730cec29def4f5d29b8e27e6be200b431db1887.tar.gz
macaw-f730cec29def4f5d29b8e27e6be200b431db1887.tar.bz2
macaw-f730cec29def4f5d29b8e27e6be200b431db1887.zip
fix: chat list ordering now concrete, unaffected by unpredictable runtime task order
-rw-r--r--src/main.rs10
1 files 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<JID, Contact>,
users: HashMap<JID, User>,
presences: HashMap<JID, Presence>,
- chats: IndexMap<JID, (Chat, ChatMessage)>,
+ chats: IndexMap<JID, (Chat, Option<ChatMessage>)>,
subscription_requests: HashSet<JID>,
open_chat: Option<MessageView>,
new_chat: Option<NewChat>,
@@ -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()
}