From e5da10093d68339247ac6c2866348757128b7e0d Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Sun, 1 Dec 2019 16:09:39 +0200 Subject: [PATCH] ui/listing: use MailListingTrait instead of ListingTrait --- ui/src/components/mail/listing.rs | 4 ++-- ui/src/components/mail/listing/plain.rs | 10 ++++++++++ ui/src/components/mail/listing/thread.rs | 11 +++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs index 4ee5536d..b85d00f9 100644 --- a/ui/src/components/mail/listing.rs +++ b/ui/src/components/mail/listing.rs @@ -136,7 +136,7 @@ pub enum ListingComponent { use crate::ListingComponent::*; impl core::ops::Deref for ListingComponent { - type Target = dyn ListingTrait; + type Target = dyn MailListingTrait; fn deref(&self) -> &Self::Target { match &self { @@ -149,7 +149,7 @@ impl core::ops::Deref for ListingComponent { } impl core::ops::DerefMut for ListingComponent { - fn deref_mut(&mut self) -> &mut (dyn ListingTrait + 'static) { + fn deref_mut(&mut self) -> &mut (dyn MailListingTrait + 'static) { match self { Compact(l) => l, Plain(l) => l, diff --git a/ui/src/components/mail/listing/plain.rs b/ui/src/components/mail/listing/plain.rs index e351d56c..eb79c350 100644 --- a/ui/src/components/mail/listing/plain.rs +++ b/ui/src/components/mail/listing/plain.rs @@ -70,11 +70,20 @@ pub struct PlainListing { unfocused: bool, view: MailView, row_updates: StackVec, + _row_updates: StackVec, movement: Option, id: ComponentId, } +impl MailListingTrait for PlainListing { + fn row_updates(&mut self) -> &mut StackVec { + &mut self._row_updates + } + + fn update_line(&mut self, _context: &Context, _thread_hash: ThreadHash) {} +} + impl ListingTrait for PlainListing { fn coordinates(&self) -> (usize, usize) { (self.new_cursor_pos.0, self.new_cursor_pos.1) @@ -467,6 +476,7 @@ impl PlainListing { filtered_order: FnvHashMap::default(), selection: FnvHashMap::default(), row_updates: StackVec::new(), + _row_updates: StackVec::new(), data_columns: DataColumns::default(), dirty: true, force_draw: true, diff --git a/ui/src/components/mail/listing/thread.rs b/ui/src/components/mail/listing/thread.rs index bd4a3a71..5d005e6a 100644 --- a/ui/src/components/mail/listing/thread.rs +++ b/ui/src/components/mail/listing/thread.rs @@ -37,6 +37,7 @@ pub struct ThreadListing { /// Cache current view. content: CellBuffer, + row_updates: StackVec, locations: Vec, /// If we must redraw on next redraw event dirty: bool, @@ -48,6 +49,14 @@ pub struct ThreadListing { id: ComponentId, } +impl MailListingTrait for ThreadListing { + fn row_updates(&mut self) -> &mut StackVec { + &mut self.row_updates + } + + fn update_line(&mut self, _context: &Context, _thread_hash: ThreadHash) {} +} + impl ListingTrait for ThreadListing { fn coordinates(&self) -> (usize, usize) { (self.new_cursor_pos.0, self.new_cursor_pos.1) @@ -56,6 +65,7 @@ impl ListingTrait for ThreadListing { self.new_cursor_pos = (coordinates.0, coordinates.1, 0); self.unfocused = false; self.locations.clear(); + self.row_updates.clear(); self.initialised = false; } fn draw_list(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) { @@ -230,6 +240,7 @@ impl ThreadListing { sort: (Default::default(), Default::default()), subsort: (Default::default(), Default::default()), content, + row_updates: StackVec::new(), locations: Vec::new(), dirty: true, unfocused: false,