listing: redraw on EnvelopeUpdate events

async
Manos Pitsidianakis 2020-05-11 20:52:45 +03:00
parent c5fe511d95
commit a86c1cbb26
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
4 changed files with 70 additions and 0 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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;