From a86c1cbb26a038ca81cf96f946ca8fe52c13eeaf Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Mon, 11 May 2020 20:52:45 +0300 Subject: [PATCH] listing: redraw on EnvelopeUpdate events --- src/components/mail/listing/compact.rs | 21 ++++++++++++++++++++ src/components/mail/listing/conversations.rs | 21 ++++++++++++++++++++ src/components/mail/listing/plain.rs | 14 +++++++++++++ src/components/mail/view/thread.rs | 14 +++++++++++++ 4 files changed, 70 insertions(+) diff --git a/src/components/mail/listing/compact.rs b/src/components/mail/listing/compact.rs index bd12d8f47..e7f204396 100644 --- a/src/components/mail/listing/compact.rs +++ b/src/components/mail/listing/compact.rs @@ -1384,6 +1384,27 @@ impl Component for CompactListing { self.view .process_event(&mut UIEvent::EnvelopeRename(*old_hash, *new_hash), context); } + UIEvent::EnvelopeUpdate(ref env_hash) => { + let account = &context.accounts[self.cursor_pos.0]; + let threads = &account.collection.threads[&self.cursor_pos.1]; + if !account.collection.contains_key(&env_hash) { + return false; + } + let new_env_thread_node_hash = account.collection.get_env(*env_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_node_hash].group); + if self.order.contains_key(&thread) { + self.row_updates.push(thread); + } + + self.dirty = true; + + self.view + .process_event(&mut UIEvent::EnvelopeUpdate(*env_hash), context); + } UIEvent::ChangeMode(UIMode::Normal) => { self.dirty = true; } diff --git a/src/components/mail/listing/conversations.rs b/src/components/mail/listing/conversations.rs index 126c65e1f..f2b054797 100644 --- a/src/components/mail/listing/conversations.rs +++ b/src/components/mail/listing/conversations.rs @@ -1229,6 +1229,27 @@ impl Component for ConversationsListing { self.view .process_event(&mut UIEvent::EnvelopeRename(*old_hash, *new_hash), context); } + UIEvent::EnvelopeUpdate(ref env_hash) => { + let account = &context.accounts[self.cursor_pos.0]; + let threads = &account.collection.threads[&self.cursor_pos.1]; + if !account.collection.contains_key(&env_hash) { + return false; + } + let env_thread_node_hash = account.collection.get_env(*env_hash).thread(); + if !threads.thread_nodes.contains_key(&env_thread_node_hash) { + return false; + } + let thread: ThreadHash = + threads.find_group(threads.thread_nodes()[&env_thread_node_hash].group); + if self.order.contains_key(&thread) { + self.row_updates.push(thread); + } + + self.dirty = true; + + self.view + .process_event(&mut UIEvent::EnvelopeUpdate(*env_hash), context); + } UIEvent::Action(ref action) => match action { Action::SubSort(field, order) if !self.unfocused => { debug!("SubSort {:?} , {:?}", field, order); diff --git a/src/components/mail/listing/plain.rs b/src/components/mail/listing/plain.rs index d7e45e388..01b94251b 100644 --- a/src/components/mail/listing/plain.rs +++ b/src/components/mail/listing/plain.rs @@ -1206,6 +1206,20 @@ impl Component for PlainListing { self.view .process_event(&mut UIEvent::EnvelopeRename(*old_hash, *new_hash), context); } + UIEvent::EnvelopeUpdate(ref env_hash) => { + let account = &context.accounts[self.cursor_pos.0]; + if !account.collection.contains_key(env_hash) + || !account.collection[&self.cursor_pos.1].contains(env_hash) + { + return false; + } + + self.row_updates.push(*env_hash); + self.dirty = true; + + self.view + .process_event(&mut UIEvent::EnvelopeUpdate(*env_hash), context); + } UIEvent::ChangeMode(UIMode::Normal) => { self.dirty = true; } diff --git a/src/components/mail/view/thread.rs b/src/components/mail/view/thread.rs index 35d088639..4ce6877ec 100644 --- a/src/components/mail/view/thread.rs +++ b/src/components/mail/view/thread.rs @@ -1115,6 +1115,20 @@ impl Component for ThreadView { self.mailview .process_event(&mut UIEvent::EnvelopeRename(*old_hash, *new_hash), context); } + UIEvent::EnvelopeUpdate(ref env_hash) => { + let account = &context.accounts[self.coordinates.0]; + for e in self.entries.iter_mut() { + if e.msg_hash == *env_hash { + let seen: bool = account.collection.get_env(*env_hash).is_seen(); + if seen != e.seen { + self.dirty = true; + } + e.seen = seen; + } + } + self.mailview + .process_event(&mut UIEvent::EnvelopeUpdate(*env_hash), context); + } _ => { if self.mailview.process_event(event, context) { return true;