diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 10 |
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() } |