diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-05-12 17:38:08 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-10 19:40:48 +0300 |
commit | 2dec7fa6b6a4b011b03142e02b94c9a91e73fe3c (patch) | |
tree | 9c7cb9d726e85cee6e93012436ef9bc11396af7b /ui/src/components/mail/listing.rs | |
parent | 1e7e99f499e3ff32b58264e40db9032f59d99bb4 (diff) |
ui: set plain/threaded/compact keeps mailbox position
closes #109
Diffstat (limited to 'ui/src/components/mail/listing.rs')
-rw-r--r-- | ui/src/components/mail/listing.rs | 60 |
1 files changed, 15 insertions, 45 deletions
diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs index 68e596fa..52568b87 100644 --- a/ui/src/components/mail/listing.rs +++ b/ui/src/components/mail/listing.rs @@ -235,59 +235,29 @@ impl Component for Listing { } UIEvent::Action(ref action) => match action { Action::Listing(ListingAction::SetPlain) => { - let new_l = match self.component { - Plain(_) => { - return true; - } - Threaded(ref mut l) => { - let mut new_l = PlainListing::default(); - new_l.set_coordinates(l.coordinates()); - new_l - } - Compact(ref mut l) => { - let mut new_l = PlainListing::default(); - new_l.set_coordinates(l.coordinates()); - new_l - } - }; + if let Plain(_) = self.component { + return true; + } + let mut new_l = PlainListing::default(); + new_l.set_coordinates((self.cursor_pos.0, self.cursor_pos.1, None)); self.component = Plain(new_l); return true; } Action::Listing(ListingAction::SetThreaded) => { - let new_l = match self.component { - Threaded(_) => { - return true; - } - Plain(ref mut l) => { - let mut new_l = ThreadListing::default(); - new_l.set_coordinates(l.coordinates()); - new_l - } - Compact(ref mut l) => { - let mut new_l = ThreadListing::default(); - new_l.set_coordinates(l.coordinates()); - new_l - } - }; + if let Threaded(_) = self.component { + return true; + } + let mut new_l = ThreadListing::default(); + new_l.set_coordinates((self.cursor_pos.0, self.cursor_pos.1, None)); self.component = Threaded(new_l); return true; } Action::Listing(ListingAction::SetCompact) => { - let new_l = match self.component { - Compact(_) => { - return true; - } - Threaded(ref mut l) => { - let mut new_l = CompactListing::default(); - new_l.set_coordinates(l.coordinates()); - new_l - } - Plain(ref mut l) => { - let mut new_l = CompactListing::default(); - new_l.set_coordinates(l.coordinates()); - new_l - } - }; + if let Compact(_) = self.component { + return true; + } + let mut new_l = CompactListing::default(); + new_l.set_coordinates((self.cursor_pos.0, self.cursor_pos.1, None)); self.component = Compact(new_l); return true; } |