Browse Source

melib: replace find_thread_group with find_root_hash

thread_group property of ThreadNode doesn't yet reflect the actual root
ThreadNode (the root of the thread, that is). So find the root manually
instead.
jmap
Manos Pitsidianakis 2 years ago
parent
commit
f8a1a6caa5
Signed by: epilys GPG Key ID: 73627C2F690DF710
  1. 13
      melib/src/thread.rs
  2. 6
      ui/src/components/mail/listing/compact.rs
  3. 10
      ui/src/components/mail/listing/conversations.rs

13
melib/src/thread.rs

@ -612,6 +612,17 @@ impl<'a> Iterator for RootIterator<'a> {
}
}
pub fn find_root_hash(buf: &FnvHashMap<ThreadHash, ThreadNode>, h: ThreadHash) -> ThreadHash {
if buf[&h].parent.is_none() {
return h;
}
let p = buf[&h].parent.unwrap();
if buf[&p].message.is_none() {
return h;
}
find_root_hash(buf, p)
}
pub fn find_thread_group(buf: &FnvHashMap<ThreadHash, ThreadNode>, h: ThreadHash) -> ThreadHash {
if buf[&h].thread_group == h {
return h;
@ -654,7 +665,7 @@ fn union(buf: &mut FnvHashMap<ThreadHash, ThreadNode>, x: ThreadHash, y: ThreadH
impl Threads {
pub fn is_snoozed(&self, h: ThreadHash) -> bool {
let root = find_thread_group(&self.thread_nodes, h);
let root = find_root_hash(&self.thread_nodes, h);
self.thread_nodes[&root].snoozed()
}
pub fn find(&mut self, i: ThreadHash) -> ThreadHash {

6
ui/src/components/mail/listing/compact.rs

@ -395,7 +395,7 @@ impl ListingTrait for CompactListing {
if !threads.thread_nodes.contains_key(&env_hash_thread_hash) {
continue;
}
let thread_group = melib::find_thread_group(
let thread_group = melib::find_root_hash(
&threads.thread_nodes,
threads.thread_nodes[&env_hash_thread_hash].thread_group(),
);
@ -1175,7 +1175,7 @@ impl Component for CompactListing {
if !threads.thread_nodes.contains_key(&new_env_thread_hash) {
return false;
}
let thread_group = melib::find_thread_group(
let thread_group = melib::find_root_hash(
&threads.thread_nodes,
threads.thread_nodes[&new_env_thread_hash].thread_group(),
);
@ -1183,7 +1183,7 @@ impl Component for CompactListing {
.order
.iter()
.find(|(n, _)| {
melib::find_thread_group(
melib::find_root_hash(
&threads.thread_nodes,
threads.thread_nodes[&n].thread_group(),
) == thread_group

10
ui/src/components/mail/listing/conversations.rs

@ -372,10 +372,8 @@ impl ListingTrait for ConversationsListing {
if !threads.thread_nodes.contains_key(&env_hash_thread_hash) {
continue;
}
let thread_group = melib::find_thread_group(
&threads.thread_nodes,
threads.thread_nodes[&env_hash_thread_hash].thread_group(),
);
let thread_group =
melib::find_root_hash(&threads.thread_nodes, env_hash_thread_hash);
if self.filtered_order.contains_key(&thread_group) {
continue;
}
@ -1066,7 +1064,7 @@ impl Component for ConversationsListing {
if !threads.thread_nodes.contains_key(&new_env_thread_hash) {
return false;
}
let thread_group = melib::find_thread_group(
let thread_group = melib::find_root_hash(
&threads.thread_nodes,
threads.thread_nodes[&new_env_thread_hash].thread_group(),
);
@ -1074,7 +1072,7 @@ impl Component for ConversationsListing {
.order
.iter()
.find(|(n, _)| {
melib::find_thread_group(
melib::find_root_hash(
&threads.thread_nodes,
threads.thread_nodes[&n].thread_group(),
) == thread_group

Loading…
Cancel
Save