diff options
Diffstat (limited to 'ui/src/components/mail/listing/conversations.rs')
-rw-r--r-- | ui/src/components/mail/listing/conversations.rs | 60 |
1 files changed, 18 insertions, 42 deletions
diff --git a/ui/src/components/mail/listing/conversations.rs b/ui/src/components/mail/listing/conversations.rs index c9c7cc8d..36aa5bd3 100644 --- a/ui/src/components/mail/listing/conversations.rs +++ b/ui/src/components/mail/listing/conversations.rs @@ -82,6 +82,7 @@ pub struct ConversationsListing { /// (x, y, z): x is accounts, y is folders, z is index inside a folder. cursor_pos: (usize, usize, usize), new_cursor_pos: (usize, usize, usize), + folder_hash: FolderHash, length: usize, sort: (SortField, SortOrder), subsort: (SortField, SortOrder), @@ -152,8 +153,7 @@ impl ListingTrait for ConversationsListing { let thread_hash = self.get_thread_under_cursor(idx, context); let account = &context.accounts[self.cursor_pos.0]; - let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash(); - let threads = &account.collection.threads[&folder_hash]; + let threads = &account.collection.threads[&self.folder_hash]; let thread = threads.thread_ref(thread_hash); let fg_color = if thread.unseen() > 0 { @@ -404,10 +404,9 @@ impl ListingTrait for ConversationsListing { } let account = &context.accounts[self.cursor_pos.0]; - let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash(); - match account.search(&self.filter_term, self.sort, folder_hash) { + match account.search(&self.filter_term, self.sort, self.folder_hash) { Ok(results) => { - let threads = &account.collection.threads[&folder_hash]; + let threads = &account.collection.threads[&self.folder_hash]; for env_hash in results { if !account.collection.contains_key(&env_hash) { continue; @@ -495,6 +494,7 @@ impl ConversationsListing { ConversationsListing { cursor_pos: (0, 1, 0), new_cursor_pos: (0, 0, 0), + folder_hash: 0, length: 0, sort: (Default::default(), Default::default()), subsort: (SortField::Date, SortOrder::Desc), @@ -524,11 +524,7 @@ impl ConversationsListing { hash: ThreadHash, ) -> EntryStrings { let thread = threads.thread_ref(hash); - let folder_hash = &context.accounts[self.cursor_pos.0][self.cursor_pos.1] - .unwrap() - .folder - .hash(); - let folder = &context.accounts[self.cursor_pos.0].folder_confs[&folder_hash]; + let folder = &context.accounts[self.cursor_pos.0].folder_confs[&self.folder_hash]; let mut tags = String::new(); let mut colors = SmallVec::new(); let backend_lck = context.accounts[self.cursor_pos.0].backend.read().unwrap(); @@ -605,7 +601,7 @@ impl ConversationsListing { } self.cursor_pos.1 = self.new_cursor_pos.1; self.cursor_pos.0 = self.new_cursor_pos.0; - let folder_hash = if let Some(h) = context.accounts[self.cursor_pos.0] + self.folder_hash = if let Some(h) = context.accounts[self.cursor_pos.0] .folders_order .get(self.cursor_pos.1) { @@ -618,10 +614,11 @@ impl ConversationsListing { // Get mailbox as a reference. // - match context.accounts[self.cursor_pos.0].status(folder_hash) { + match context.accounts[self.cursor_pos.0].status(self.folder_hash) { Ok(()) => {} Err(_) => { - let message: String = context.accounts[self.cursor_pos.0][folder_hash].to_string(); + let message: String = + context.accounts[self.cursor_pos.0][self.folder_hash].to_string(); self.content = CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context); self.length = 0; @@ -638,7 +635,7 @@ impl ConversationsListing { } } - let threads = &context.accounts[self.cursor_pos.0].collection.threads[&folder_hash]; + let threads = &context.accounts[self.cursor_pos.0].collection.threads[&self.folder_hash]; self.all_threads.clear(); let mut roots = threads.roots(); threads.group_inner_sort_by( @@ -898,9 +895,6 @@ impl ConversationsListing { } fn get_thread_under_cursor(&self, cursor: usize, context: &Context) -> ThreadHash { - //let account = &context.accounts[self.cursor_pos.0]; - //let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash(); - //let threads = &account.collection.threads[&folder_hash]; if self.filter_term.is_empty() { *self .order @@ -919,8 +913,7 @@ impl ConversationsListing { fn update_line(&mut self, context: &Context, thread_hash: ThreadHash) { let account = &context.accounts[self.cursor_pos.0]; - let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash(); - let threads = &account.collection.threads[&folder_hash]; + let threads = &account.collection.threads[&self.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]; @@ -1202,8 +1195,7 @@ impl Component for ConversationsListing { } UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => { let account = &context.accounts[self.cursor_pos.0]; - let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash(); - let threads = &account.collection.threads[&folder_hash]; + let threads = &account.collection.threads[&self.folder_hash]; if !account.collection.contains_key(&new_hash) { return false; } @@ -1228,7 +1220,7 @@ impl Component for ConversationsListing { self.subsort = (*field, *order); // FIXME subsort //if !self.filtered_selection.is_empty() { - // let threads = &account.collection.threads[&folder_hash]; + // let threads = &account.collection.threads[&self.folder_hash]; // threads.vec_inner_sort_by(&mut self.filtered_selection, self.sort, &account.collection); //} else { // self.refresh_mailbox(context); @@ -1241,13 +1233,8 @@ impl Component for ConversationsListing { /* self.sort = (*field, *order); if !self.filtered_selection.is_empty() { - let folder_hash = context.accounts[self.cursor_pos.0] - [self.cursor_pos.1] - .unwrap() - .folder - .hash(); let threads = &context.accounts[self.cursor_pos.0].collection.threads - [&folder_hash]; + [&self.folder_hash]; threads.vec_inner_sort_by( &mut self.filtered_selection, self.sort, @@ -1263,11 +1250,10 @@ impl Component for ConversationsListing { Action::ToggleThreadSnooze if !self.unfocused => { let thread = self.get_thread_under_cursor(self.cursor_pos.2, context); let account = &mut context.accounts[self.cursor_pos.0]; - let folder_hash = account[self.cursor_pos.1].unwrap().folder.hash(); account .collection .threads - .entry(folder_hash) + .entry(self.folder_hash) .and_modify(|threads| { let is_snoozed = threads.thread_ref(thread).snoozed(); threads.thread_ref_mut(thread).set_snoozed(!is_snoozed); @@ -1283,22 +1269,12 @@ impl Component for ConversationsListing { } match *event { UIEvent::MailboxUpdate((ref idxa, ref idxf)) - if context.accounts[self.new_cursor_pos.0] - .folders_order - .get(self.new_cursor_pos.1) - .map(|&folder_hash| (*idxa, *idxf) == (self.new_cursor_pos.0, folder_hash)) - .unwrap_or(false) => + if (*idxa, *idxf) == (self.new_cursor_pos.0, self.folder_hash) => { self.refresh_mailbox(context); self.set_dirty(true); } - UIEvent::StartupCheck(ref f) - if context.accounts[self.new_cursor_pos.0] - .folders_order - .get(self.new_cursor_pos.1) - .map(|&folder_hash| *f == folder_hash) - .unwrap_or(false) => - { + UIEvent::StartupCheck(ref f) if *f == self.folder_hash => { self.refresh_mailbox(context); self.set_dirty(true); } |