state: remove overlay widgets on ComponentKill events

jmap-eventsource
Manos Pitsidianakis 2020-10-20 23:19:13 +03:00
parent eb36034740
commit 4b91de3d59
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 4 additions and 2 deletions

View File

@ -1174,14 +1174,16 @@ impl State {
self.display_messages_pos = self.display_messages.len() - 1;
self.redraw();
}
UIEvent::ComponentKill(ref id) if self.overlay.iter().any(|c| c.id() == *id) => {
let pos = self.overlay.iter().position(|c| c.id() == *id).unwrap();
self.overlay.remove(pos);
}
UIEvent::FinishedUIDialog(ref id, ref mut results)
if self.overlay.iter().any(|c| c.id() == *id) =>
{
if let Some(ref mut action @ Some(_)) = results.downcast_mut::<Option<Action>>() {
self.exec_command(action.take().unwrap());
let pos = self.overlay.iter().position(|c| c.id() == *id).unwrap();
self.overlay.remove(pos);
return;
}
}