From 76c4f1b67f6ce7de48b8d297c17a1f5e72401086 Mon Sep 17 00:00:00 2001 From: ChristianVisintin Date: Fri, 25 Dec 2020 10:00:24 +0100 Subject: [PATCH] Close popups also with --- src/ui/activities/auth_activity/input.rs | 11 ++++------ .../activities/filetransfer_activity/input.rs | 22 +++++++------------ 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/ui/activities/auth_activity/input.rs b/src/ui/activities/auth_activity/input.rs index b46f2fd..24458de 100644 --- a/src/ui/activities/auth_activity/input.rs +++ b/src/ui/activities/auth_activity/input.rs @@ -405,7 +405,7 @@ impl AuthActivity { pub(super) fn handle_input_event_mode_popup_alert(&mut self, ev: &InputEvent) { // Only enter should be allowed here if let InputEvent::Key(key) = ev { - if let KeyCode::Enter = key.code { + if matches!(key.code, KeyCode::Esc | KeyCode::Enter) { self.input_mode = InputMode::Form; // Hide popup } } @@ -417,12 +417,9 @@ impl AuthActivity { pub(super) fn handle_input_event_mode_popup_help(&mut self, ev: &InputEvent) { // If enter, close popup if let InputEvent::Key(key) = ev { - match key.code { - KeyCode::Enter | KeyCode::Esc => { - // Set input mode back to form - self.input_mode = InputMode::Form; - } - _ => { /* Nothing to do */ } + if matches!(key.code, KeyCode::Esc | KeyCode::Enter) { + // Set input mode back to form + self.input_mode = InputMode::Form; } } } diff --git a/src/ui/activities/filetransfer_activity/input.rs b/src/ui/activities/filetransfer_activity/input.rs index 0b728aa..2455b58 100644 --- a/src/ui/activities/filetransfer_activity/input.rs +++ b/src/ui/activities/filetransfer_activity/input.rs @@ -605,7 +605,7 @@ impl FileTransferActivity { pub(super) fn handle_input_event_mode_popup_alert(&mut self, ev: &InputEvent) { // If enter, close popup if let InputEvent::Key(key) = ev { - if let KeyCode::Enter = key.code { + if matches!(key.code, KeyCode::Esc | KeyCode::Enter) { // Set input mode back to explorer self.input_mode = InputMode::Explorer; } @@ -618,12 +618,9 @@ impl FileTransferActivity { pub(super) fn handle_input_event_mode_popup_fileinfo(&mut self, ev: &InputEvent) { // If enter, close popup if let InputEvent::Key(key) = ev { - match key.code { - KeyCode::Enter | KeyCode::Esc => { - // Set input mode back to explorer - self.input_mode = InputMode::Explorer; - } - _ => { /* Nothing to do */ } + if matches!(key.code, KeyCode::Esc | KeyCode::Enter) { + // Set input mode back to explorer + self.input_mode = InputMode::Explorer; } } } @@ -634,12 +631,9 @@ impl FileTransferActivity { pub(super) fn handle_input_event_mode_popup_help(&mut self, ev: &InputEvent) { // If enter, close popup if let InputEvent::Key(key) = ev { - match key.code { - KeyCode::Enter | KeyCode::Esc => { - // Set input mode back to explorer - self.input_mode = InputMode::Explorer; - } - _ => { /* Nothing to do */ } + if matches!(key.code, KeyCode::Esc | KeyCode::Enter) { + // Set input mode back to explorer + self.input_mode = InputMode::Explorer; } } } @@ -650,7 +644,7 @@ impl FileTransferActivity { pub(super) fn handle_input_event_mode_popup_fatal(&mut self, ev: &InputEvent) { // If enter, close popup if let InputEvent::Key(key) = ev { - if let KeyCode::Enter = key.code { + if matches!(key.code, KeyCode::Esc | KeyCode::Enter) { // Set quit to true; since a fatal error happened self.disconnect(); }