diff --git a/melib/src/thread.rs b/melib/src/thread.rs index 405b68d0c..1443b86bd 100644 --- a/melib/src/thread.rs +++ b/melib/src/thread.rs @@ -747,9 +747,17 @@ impl Threads { { return false; } + + let message_id = envelopes_lck[&env_hash].message_id().raw(); + if self.message_ids.contains_key(message_id) + && !self.missing_message_ids.contains(message_id) + { + return false; + } + let new_id = self .message_ids - .get(envelopes_lck[&env_hash].message_id().raw()) + .get(message_id) .cloned() .unwrap_or_else(|| ThreadNodeHash::new()); { diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs index 96a398274..7825320a8 100644 --- a/ui/src/components/mail/listing/compact.rs +++ b/ui/src/components/mail/listing/compact.rs @@ -440,12 +440,15 @@ impl ListingTrait for CompactListing { if !account.collection.contains_key(&env_hash) { continue; } - let env_hash_thread_hash = account.collection.get_env(env_hash).thread(); - if !threads.thread_nodes.contains_key(&env_hash_thread_hash) { + let env_thread_node_hash = account.collection.get_env(env_hash).thread(); + if !threads + .thread_nodes + .contains_key(&env_thread_node_hash) + { continue; } let thread = - threads.find_group(threads.thread_nodes[&env_hash_thread_hash].group); + threads.find_group(threads.thread_nodes[&env_thread_node_hash].group); if self.filtered_order.contains_key(&thread) { continue; } @@ -980,8 +983,8 @@ impl CompactListing { let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash(); let threads = &account.collection.threads[&folder_hash]; let thread = threads.thread_ref(thread_hash); - // FIXME: Thread root doesn't nessessarily have message set - if let Some(env_hash) = threads.thread_nodes()[&thread.root()].message() { + let thread_node_hash = threads.thread_group_iter(thread_hash).next().unwrap().1; + if let Some(env_hash) = threads.thread_nodes()[&thread_node_hash].message() { if !account.contains_key(env_hash) { /* The envelope has been renamed or removed, so wait for the appropriate event to * arrive */ @@ -1311,12 +1314,12 @@ impl Component for CompactListing { if !account.collection.contains_key(&new_hash) { return false; } - let new_env_thread_hash = account.collection.get_env(*new_hash).thread(); - if !threads.thread_nodes.contains_key(&new_env_thread_hash) { + let new_env_thread_node_hash = account.collection.get_env(*new_hash).thread(); + if !threads.thread_nodes.contains_key(&new_env_thread_node_hash) { return false; } let thread: ThreadHash = - threads.find_group(threads.thread_nodes()[&new_env_thread_hash].group); + threads.find_group(threads.thread_nodes()[&new_env_thread_node_hash].group); if self.order.contains_key(&thread) { self.row_updates.push(thread); } diff --git a/ui/src/components/mail/listing/conversations.rs b/ui/src/components/mail/listing/conversations.rs index 314856487..c9c7cc8d1 100644 --- a/ui/src/components/mail/listing/conversations.rs +++ b/ui/src/components/mail/listing/conversations.rs @@ -412,12 +412,12 @@ impl ListingTrait for ConversationsListing { if !account.collection.contains_key(&env_hash) { continue; } - let env_hash_thread_hash = account.collection.get_env(env_hash).thread(); - if !threads.thread_nodes.contains_key(&env_hash_thread_hash) { + let env_thread_node_hash = account.collection.get_env(env_hash).thread(); + if !threads.thread_nodes.contains_key(&env_thread_node_hash) { continue; } let thread = - threads.find_group(threads.thread_nodes[&env_hash_thread_hash].group); + threads.find_group(threads.thread_nodes[&env_thread_node_hash].group); if self.filtered_order.contains_key(&thread) { continue; } @@ -922,10 +922,11 @@ impl ConversationsListing { let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash(); let threads = &account.collection.threads[&folder_hash]; let thread = threads.thread_ref(thread_hash); + let thread_node_hash = threads.thread_group_iter(thread_hash).next().unwrap().1; let idx: usize = self.order[&thread_hash]; let width = self.content.size().0; - let env_hash = threads.thread_nodes()[&thread.root()].message().unwrap(); + let env_hash = threads.thread_nodes()[&thread_node_hash].message().unwrap(); let fg_color = if thread.unseen() > 0 { Color::Byte(0) @@ -1206,12 +1207,12 @@ impl Component for ConversationsListing { if !account.collection.contains_key(&new_hash) { return false; } - let new_env_thread_hash = account.collection.get_env(*new_hash).thread(); - if !threads.thread_nodes.contains_key(&new_env_thread_hash) { + let env_thread_node_hash = account.collection.get_env(*new_hash).thread(); + if !threads.thread_nodes.contains_key(&env_thread_node_hash) { return false; } let thread: ThreadHash = - threads.find_group(threads.thread_nodes()[&new_env_thread_hash].group); + threads.find_group(threads.thread_nodes()[&env_thread_node_hash].group); if self.order.contains_key(&thread) { self.row_updates.push(thread); } diff --git a/ui/src/components/mail/listing/plain.rs b/ui/src/components/mail/listing/plain.rs index 1a9095d37..060e093ff 100644 --- a/ui/src/components/mail/listing/plain.rs +++ b/ui/src/components/mail/listing/plain.rs @@ -62,7 +62,7 @@ pub struct PlainListing { filtered_selection: Vec, filtered_order: FnvHashMap, selection: FnvHashMap, - thread_hashes: FnvHashMap, + thread_node_hashes: FnvHashMap, local_collection: Vec, /// If we must redraw on next redraw event dirty: bool, @@ -90,7 +90,7 @@ impl MailListingTrait for PlainListing { self.selection .iter() .filter(|(_, v)| **v) - .map(|(k, _)| self.thread_hashes[k]) + .map(|(k, _)| self.thread_node_hashes[k]) .collect() } else { let mut ret = SmallVec::new(); @@ -481,7 +481,7 @@ impl PlainListing { subsort: (SortField::Date, SortOrder::Desc), all_envelopes: fnv::FnvHashSet::default(), local_collection: Vec::new(), - thread_hashes: FnvHashMap::default(), + thread_node_hashes: FnvHashMap::default(), order: FnvHashMap::default(), filter_term: String::new(), filtered_selection: Vec::new(), @@ -606,7 +606,7 @@ impl PlainListing { .envelopes .read() .unwrap(); - self.thread_hashes = context.accounts[self.cursor_pos.0][folder_hash] + self.thread_node_hashes = context.accounts[self.cursor_pos.0][folder_hash] .unwrap() .envelopes .iter() diff --git a/ui/src/components/mail/listing/thread.rs b/ui/src/components/mail/listing/thread.rs index 1679988d6..2cd52d93b 100644 --- a/ui/src/components/mail/listing/thread.rs +++ b/ui/src/components/mail/listing/thread.rs @@ -323,8 +323,8 @@ impl ThreadListing { let mut iter = threads.threads_iter().peekable(); /* This is just a desugared for loop so that we can use .peek() */ let mut idx = 0; - while let Some((indentation, thread_hash, has_sibling)) = iter.next() { - let thread_node = &thread_nodes[&thread_hash]; + while let Some((indentation, thread_node_hash, has_sibling)) = iter.next() { + let thread_node = &thread_nodes[&thread_node_hash]; if indentation == 0 { thread_idx += 1; @@ -350,7 +350,7 @@ impl ThreadListing { &envelope, idx, indentation, - thread_hash, + thread_node_hash, threads, &indentations, has_sibling, diff --git a/ui/src/components/mail/view/thread.rs b/ui/src/components/mail/view/thread.rs index 1635a5f82..3275d98a2 100644 --- a/ui/src/components/mail/view/thread.rs +++ b/ui/src/components/mail/view/thread.rs @@ -168,16 +168,17 @@ impl ThreadView { let thread_iter = threads.thread_group_iter(self.thread_group); self.entries.clear(); - for (line, (ind, thread_hash)) in thread_iter.enumerate() { - let entry = if let Some(msg_hash) = threads.thread_nodes()[&thread_hash].message() { + for (line, (ind, thread_node_hash)) in thread_iter.enumerate() { + let entry = if let Some(msg_hash) = threads.thread_nodes()[&thread_node_hash].message() + { let seen: bool = account.collection.get_env(msg_hash).is_seen(); - self.make_entry((ind, thread_hash, line), msg_hash, seen) + self.make_entry((ind, thread_node_hash, line), msg_hash, seen) } else { continue; }; self.entries.push(entry); match expanded_hash { - Some(expanded_hash) if expanded_hash == thread_hash => { + Some(expanded_hash) if expanded_hash == thread_node_hash => { self.new_expanded_pos = self.entries.len().saturating_sub(1); self.expanded_pos = self.new_expanded_pos + 1; }