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