diff --git a/melib/src/thread.rs b/melib/src/thread.rs index 8934fadc2..c0e87cb9e 100644 --- a/melib/src/thread.rs +++ b/melib/src/thread.rs @@ -1028,6 +1028,25 @@ impl Threads { self.rebuild_thread(reply_to_id, envelopes); true } else { + let new_id = ThreadHash::new(); + self.thread_nodes.insert( + new_id, + ThreadNode { + message: Some(env_hash), + parent: None, + date: envelopes[&env_hash].date(), + ..ThreadNode::new(new_id) + }, + ); + self.message_ids + .insert(envelopes[&env_hash].message_id().raw().to_vec(), new_id); + self.message_ids_set + .insert(envelopes[&env_hash].message_id().raw().to_vec().to_vec()); + self.missing_message_ids + .remove(envelopes[&env_hash].message_id().raw()); + envelopes.get_mut(&env_hash).unwrap().set_thread(new_id); + self.hash_set.insert(env_hash); + self.rebuild_thread(new_id, envelopes); false } /* diff --git a/ui/src/conf/accounts.rs b/ui/src/conf/accounts.rs index 52cc9a241..4fe634976 100644 --- a/ui/src/conf/accounts.rs +++ b/ui/src/conf/accounts.rs @@ -315,7 +315,6 @@ impl Account { let env_hash = envelope.hash(); let mailbox = mailbox!(&folder_hash, self.folders); mailbox.insert(env_hash); - self.collection.insert(*envelope, folder_hash); if self .sent_folder .as_ref() @@ -323,6 +322,8 @@ impl Account { .unwrap_or(false) { self.collection.insert_reply(env_hash); + } else { + self.collection.insert(*envelope, folder_hash); } let ref_folders: FnvHashMap = self.backend.folders();