diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-06 00:27:40 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-10 19:40:51 +0300 |
commit | b6c0236d24a6252aad0e6f14b5a5f41052ed854d (patch) | |
tree | f14408b0c2fd4a52539f89808da2248085b952ec /ui/src/components/mail | |
parent | 85d1aaaa69f4b37343998088f89f306c83af117f (diff) |
ui: make EnvelopeRename event not folder specific
And pass EnvelopeRename events to subviews
Diffstat (limited to 'ui/src/components/mail')
-rw-r--r-- | ui/src/components/mail/listing/compact.rs | 9 | ||||
-rw-r--r-- | ui/src/components/mail/view.rs | 32 | ||||
-rw-r--r-- | ui/src/components/mail/view/thread.rs | 21 |
3 files changed, 34 insertions, 28 deletions
diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs index d43a08d3..dad12fde 100644 --- a/ui/src/components/mail/listing/compact.rs +++ b/ui/src/components/mail/listing/compact.rs @@ -646,10 +646,7 @@ impl Component for MailboxView { self.refresh_mailbox(context); self.set_dirty(); } - UIEvent::EnvelopeRename(ref folder_hash, ref old_hash, ref new_hash) - if *folder_hash - == context.accounts[self.cursor_pos.0].folders_order[self.new_cursor_pos.1] => - { + UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => { if let Some(row) = self.order.remove(old_hash) { self.order.insert(*new_hash, row); self.highlight_line(None, ((0, row), (MAX_COLS - 1, row)), row, context); @@ -658,6 +655,8 @@ impl Component for MailboxView { } else { /* Listing has was updated in time before the event */ } + self.view + .process_event(&mut UIEvent::EnvelopeRename(*old_hash, *new_hash), context); } UIEvent::ChangeMode(UIMode::Normal) => { self.dirty = true; @@ -872,7 +871,7 @@ impl Component for CompactListing { | UIEvent::ComponentKill(_) | UIEvent::StartupCheck(_) | UIEvent::EnvelopeUpdate(_) - | UIEvent::EnvelopeRename(_, _, _) + | UIEvent::EnvelopeRename(_, _) | UIEvent::EnvelopeRemove(_) => { return self.views[self.cursor].process_event(event, context) } diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs index 461586a7..c787aae0 100644 --- a/ui/src/components/mail/view.rs +++ b/ui/src/components/mail/view.rs @@ -88,23 +88,6 @@ impl MailView { subview: Option<Box<Component>>, context: &mut Context, ) -> Self { - let account = &mut context.accounts[coordinates.0]; - let (hash, is_seen) = { - let envelope: &Envelope = &account.get_env(&coordinates.2); - (envelope.hash(), envelope.is_seen()) - }; - if !is_seen { - let folder_hash = { - let mailbox = &mut account[coordinates.1].as_mut().unwrap(); - mailbox.folder.hash() - }; - let op = { - let backend = &account.backend; - backend.operation(hash, folder_hash) - }; - let envelope: &mut Envelope = &mut account.get_env_mut(&coordinates.2); - envelope.set_seen(op).unwrap(); - } MailView { coordinates, pager, @@ -304,6 +287,19 @@ impl Component for MailView { * arrive */ return; } + let (hash, is_seen) = { + let envelope: &Envelope = &account.get_env(&self.coordinates.2); + (envelope.hash(), envelope.is_seen()) + }; + if !is_seen { + let folder_hash = { + let mailbox = &mut account[self.coordinates.1].as_mut().unwrap(); + mailbox.folder.hash() + }; + let op = account.operation(&hash); + let envelope: &mut Envelope = &mut account.get_env_mut(&self.coordinates.2); + envelope.set_seen(op).unwrap(); + } let envelope: &Envelope = &account.get_env(&self.coordinates.2); if self.mode == ViewMode::Raw { @@ -746,7 +742,7 @@ impl Component for MailView { } self.dirty = true; } - UIEvent::EnvelopeRename(_, old_hash, new_hash) if old_hash == self.coordinates.2 => { + UIEvent::EnvelopeRename(old_hash, new_hash) => { self.coordinates.2 = new_hash; } _ => { diff --git a/ui/src/components/mail/view/thread.rs b/ui/src/components/mail/view/thread.rs index 4b8be368..7b1fca8c 100644 --- a/ui/src/components/mail/view/thread.rs +++ b/ui/src/components/mail/view/thread.rs @@ -291,8 +291,7 @@ impl ThreadView { /* Box character drawing stuff */ let mut x = 0; for i in 0..e.index.0 { - let color = - INDENTATION_COLORS[(i).wrapping_rem(INDENTATION_COLORS.len())]; + let color = INDENTATION_COLORS[(i).wrapping_rem(INDENTATION_COLORS.len())]; change_colors( &mut content, ((x, 2 * y), (x + 3, 2 * y + 1)), @@ -408,6 +407,7 @@ impl ThreadView { /// draw the list fn draw_list(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) { + /* Make space on the left for the scrollbar */ let mut upper_left = pos_inc(upper_left!(area), (1, 0)); let bottom_right = bottom_right!(area); let (width, height) = self.content.size(); @@ -613,9 +613,11 @@ impl ThreadView { let i = if let Some(i) = thread_node.message() { i } else { - threads.thread_nodes()[&thread_node.children()[0]] - .message() - .unwrap() + let mut iter_ptr = thread_node.children()[0]; + while threads.thread_nodes()[&iter_ptr].message().is_none() { + iter_ptr = threads.thread_nodes()[&iter_ptr].children()[0]; + } + threads.thread_nodes()[&iter_ptr].message().unwrap() }; let envelope: &Envelope = account.get_env(&i); @@ -1013,6 +1015,15 @@ impl Component for ThreadView { UIEvent::Resize => { self.set_dirty(); } + UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => { + for e in self.entries.iter_mut() { + if e.msg_hash == *old_hash { + e.msg_hash = *new_hash; + } + } + self.mailview + .process_event(&mut UIEvent::EnvelopeRename(*old_hash, *new_hash), context); + } _ => { if self.mailview.process_event(event, context) { return true; |