summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2020-01-18 05:02:03 +0200
committerManos Pitsidianakis <el13635@mail.ntua.gr>2020-01-20 16:03:29 +0200
commite07b5faf6edabf5e6455805b70884aef75ba7157 (patch)
treea0d60ca961699013d41d3e65103fbb4b224db21d /ui
parent350fafb51597e0e07fab731e111ae92b409b7834 (diff)
melib/threads: already-exists check in threads insert
Diffstat (limited to 'ui')
-rw-r--r--ui/src/components/mail/listing/compact.rs19
-rw-r--r--ui/src/components/mail/listing/conversations.rs15
-rw-r--r--ui/src/components/mail/listing/plain.rs8
-rw-r--r--ui/src/components/mail/listing/thread.rs6
-rw-r--r--ui/src/components/mail/view/thread.rs9
5 files changed, 31 insertions, 26 deletions
diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs
index 96a39827..7825320a 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 31485648..c9c7cc8d 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 1a9095d3..060e093f 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<EnvelopeHash>,
filtered_order: FnvHashMap<EnvelopeHash, usize>,
selection: FnvHashMap<EnvelopeHash, bool>,
- thread_hashes: FnvHashMap<EnvelopeHash, ThreadNodeHash>,
+ thread_node_hashes: FnvHashMap<EnvelopeHash, ThreadNodeHash>,
local_collection: Vec<EnvelopeHash>,
/// 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 1679988d..2cd52d93 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 1635a5f8..3275d98a 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;
}