ui: set plain/threaded/compact keeps mailbox position

closes #109
embed
Manos Pitsidianakis 2019-05-12 17:38:08 +03:00
parent 1e7e99f499
commit 2dec7fa6b6
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 15 additions and 45 deletions

View File

@ -235,59 +235,29 @@ impl Component for Listing {
} }
UIEvent::Action(ref action) => match action { UIEvent::Action(ref action) => match action {
Action::Listing(ListingAction::SetPlain) => { Action::Listing(ListingAction::SetPlain) => {
let new_l = match self.component { if let Plain(_) = self.component {
Plain(_) => { return true;
return true; }
} let mut new_l = PlainListing::default();
Threaded(ref mut l) => { new_l.set_coordinates((self.cursor_pos.0, self.cursor_pos.1, None));
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
}
};
self.component = Plain(new_l); self.component = Plain(new_l);
return true; return true;
} }
Action::Listing(ListingAction::SetThreaded) => { Action::Listing(ListingAction::SetThreaded) => {
let new_l = match self.component { if let Threaded(_) = self.component {
Threaded(_) => { return true;
return true; }
} let mut new_l = ThreadListing::default();
Plain(ref mut l) => { new_l.set_coordinates((self.cursor_pos.0, self.cursor_pos.1, None));
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
}
};
self.component = Threaded(new_l); self.component = Threaded(new_l);
return true; return true;
} }
Action::Listing(ListingAction::SetCompact) => { Action::Listing(ListingAction::SetCompact) => {
let new_l = match self.component { if let Compact(_) = self.component {
Compact(_) => { return true;
return true; }
} let mut new_l = CompactListing::default();
Threaded(ref mut l) => { new_l.set_coordinates((self.cursor_pos.0, self.cursor_pos.1, None));
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
}
};
self.component = Compact(new_l); self.component = Compact(new_l);
return true; return true;
} }