fix: Updated the name of the should_ignore_quit_key to ignore_special_keys_for_textbox_input to give a better idea of what the flag is used for; also added alt keybinding for backspace

This commit is contained in:
2025-03-27 15:21:44 -06:00
parent f25829f3c1
commit cf00d7992e
80 changed files with 584 additions and 435 deletions
+2 -2
View File
@@ -98,7 +98,7 @@ mod tests {
assert!(!app.is_loading); assert!(!app.is_loading);
assert!(!app.is_routing); assert!(!app.is_routing);
assert!(!app.should_refresh); assert!(!app.should_refresh);
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(!app.cli_mode); assert!(!app.cli_mode);
} }
@@ -118,7 +118,7 @@ mod tests {
assert!(!app.is_loading); assert!(!app.is_loading);
assert!(!app.is_routing); assert!(!app.is_routing);
assert!(!app.should_refresh); assert!(!app.should_refresh);
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(!app.cli_mode); assert!(!app.cli_mode);
} }
+3 -3
View File
@@ -76,7 +76,7 @@ pub const DEFAULT_KEYBINDINGS: KeyBindings = KeyBindings {
}, },
backspace: KeyBinding { backspace: KeyBinding {
key: Key::Backspace, key: Key::Backspace,
alt: None, alt: Some(Key::Ctrl('h')),
desc: "backspace", desc: "backspace",
}, },
next_servarr: KeyBinding { next_servarr: KeyBinding {
@@ -215,9 +215,9 @@ macro_rules! matches_key {
.unwrap() .unwrap()
== $key) == $key)
}; };
($binding:ident, $key:expr, $ignore_alt_navigation:expr) => { ($binding:ident, $key:expr, $ignore_special_keys:expr) => {
$crate::app::key_binding::DEFAULT_KEYBINDINGS.$binding.key == $key $crate::app::key_binding::DEFAULT_KEYBINDINGS.$binding.key == $key
|| !$ignore_alt_navigation || !$ignore_special_keys
&& ($crate::app::key_binding::DEFAULT_KEYBINDINGS && ($crate::app::key_binding::DEFAULT_KEYBINDINGS
.$binding .$binding
.alt .alt
+71 -30
View File
@@ -5,44 +5,85 @@ mod test {
use crate::app::key_binding::{KeyBinding, DEFAULT_KEYBINDINGS}; use crate::app::key_binding::{KeyBinding, DEFAULT_KEYBINDINGS};
use crate::event::Key; use crate::event::Key;
use crate::matches_key;
#[rstest] #[rstest]
#[case(DEFAULT_KEYBINDINGS.add, Key::Char('a'), "add")] #[case(DEFAULT_KEYBINDINGS.add, Key::Char('a'), None, "add")]
#[case(DEFAULT_KEYBINDINGS.up, Key::Up, "up")] #[case(DEFAULT_KEYBINDINGS.up, Key::Up, Some(Key::Char('k')), "up")]
#[case(DEFAULT_KEYBINDINGS.down, Key::Down, "down")] #[case(DEFAULT_KEYBINDINGS.down, Key::Down, Some(Key::Char('j')), "down")]
#[case(DEFAULT_KEYBINDINGS.left, Key::Left, "left")] #[case(DEFAULT_KEYBINDINGS.left, Key::Left, Some(Key::Char('h')), "left")]
#[case(DEFAULT_KEYBINDINGS.right, Key::Right, "right")] #[case(DEFAULT_KEYBINDINGS.right, Key::Right, Some(Key::Char('l')), "right")]
#[case(DEFAULT_KEYBINDINGS.backspace, Key::Backspace, "backspace")] #[case(DEFAULT_KEYBINDINGS.backspace, Key::Backspace, Some(Key::Ctrl('h')), "backspace")]
#[case(DEFAULT_KEYBINDINGS.next_servarr, Key::Tab, "next servarr")] #[case(DEFAULT_KEYBINDINGS.next_servarr, Key::Tab, None, "next servarr")]
#[case(DEFAULT_KEYBINDINGS.previous_servarr, Key::BackTab, "previous servarr")] #[case(DEFAULT_KEYBINDINGS.previous_servarr, Key::BackTab, None, "previous servarr")]
#[case(DEFAULT_KEYBINDINGS.clear, Key::Char('c'), "clear")] #[case(DEFAULT_KEYBINDINGS.clear, Key::Char('c'), None, "clear")]
#[case(DEFAULT_KEYBINDINGS.auto_search, Key::Char('S'), "auto search")] #[case(DEFAULT_KEYBINDINGS.auto_search, Key::Char('S'), None, "auto search")]
#[case(DEFAULT_KEYBINDINGS.search, Key::Char('s'), "search")] #[case(DEFAULT_KEYBINDINGS.search, Key::Char('s'), None, "search")]
#[case(DEFAULT_KEYBINDINGS.settings, Key::Char('S'), "settings")] #[case(DEFAULT_KEYBINDINGS.settings, Key::Char('S'), None, "settings")]
#[case(DEFAULT_KEYBINDINGS.filter, Key::Char('f'), "filter")] #[case(DEFAULT_KEYBINDINGS.filter, Key::Char('f'), None, "filter")]
#[case(DEFAULT_KEYBINDINGS.sort, Key::Char('o'), "sort")] #[case(DEFAULT_KEYBINDINGS.sort, Key::Char('o'), None, "sort")]
#[case(DEFAULT_KEYBINDINGS.edit, Key::Char('e'), "edit")] #[case(DEFAULT_KEYBINDINGS.edit, Key::Char('e'), None, "edit")]
#[case(DEFAULT_KEYBINDINGS.events, Key::Char('e'), "events")] #[case(DEFAULT_KEYBINDINGS.events, Key::Char('e'), None, "events")]
#[case(DEFAULT_KEYBINDINGS.logs, Key::Char('L'), "logs")] #[case(DEFAULT_KEYBINDINGS.logs, Key::Char('L'), None, "logs")]
#[case(DEFAULT_KEYBINDINGS.tasks, Key::Char('t'), "tasks")] #[case(DEFAULT_KEYBINDINGS.tasks, Key::Char('t'), None, "tasks")]
#[case(DEFAULT_KEYBINDINGS.test, Key::Char('t'), "test")] #[case(DEFAULT_KEYBINDINGS.test, Key::Char('t'), None, "test")]
#[case(DEFAULT_KEYBINDINGS.test_all, Key::Char('T'), "test all")] #[case(DEFAULT_KEYBINDINGS.test_all, Key::Char('T'), None, "test all")]
#[case(DEFAULT_KEYBINDINGS.toggle_monitoring, Key::Char('m'), "toggle monitoring")] #[case(DEFAULT_KEYBINDINGS.toggle_monitoring, Key::Char('m'), None, "toggle monitoring")]
#[case(DEFAULT_KEYBINDINGS.refresh, Key::Ctrl('r'), "refresh")] #[case(DEFAULT_KEYBINDINGS.refresh, Key::Ctrl('r'), None, "refresh")]
#[case(DEFAULT_KEYBINDINGS.update, Key::Char('u'), "update")] #[case(DEFAULT_KEYBINDINGS.update, Key::Char('u'), None, "update")]
#[case(DEFAULT_KEYBINDINGS.home, Key::Home, "home")] #[case(DEFAULT_KEYBINDINGS.home, Key::Home, None, "home")]
#[case(DEFAULT_KEYBINDINGS.end, Key::End, "end")] #[case(DEFAULT_KEYBINDINGS.end, Key::End, None, "end")]
#[case(DEFAULT_KEYBINDINGS.delete, Key::Delete, "delete")] #[case(DEFAULT_KEYBINDINGS.delete, Key::Delete, None, "delete")]
#[case(DEFAULT_KEYBINDINGS.submit, Key::Enter, "submit")] #[case(DEFAULT_KEYBINDINGS.submit, Key::Enter, None, "submit")]
#[case(DEFAULT_KEYBINDINGS.confirm, Key::Ctrl('s'), "submit")] #[case(DEFAULT_KEYBINDINGS.confirm, Key::Ctrl('s'), None, "submit")]
#[case(DEFAULT_KEYBINDINGS.quit, Key::Char('q'), "quit")] #[case(DEFAULT_KEYBINDINGS.quit, Key::Char('q'), None, "quit")]
#[case(DEFAULT_KEYBINDINGS.esc, Key::Esc, "close")] #[case(DEFAULT_KEYBINDINGS.esc, Key::Esc, None, "close")]
fn test_default_key_bindings_and_descriptions( fn test_default_key_bindings_and_descriptions(
#[case] key_binding: KeyBinding, #[case] key_binding: KeyBinding,
#[case] expected_key: Key, #[case] expected_key: Key,
#[case] expected_alt_key: Option<Key>,
#[case] expected_desc: &str, #[case] expected_desc: &str,
) { ) {
assert_eq!(key_binding.key, expected_key); assert_eq!(key_binding.key, expected_key);
assert_eq!(key_binding.alt, expected_alt_key);
assert_str_eq!(key_binding.desc, expected_desc); assert_str_eq!(key_binding.desc, expected_desc);
} }
#[test]
fn test_matches_key_macro() {
let key = Key::Char('t');
assert!(matches_key!(test, key));
assert!(!matches_key!(test, Key::Char('T')));
}
#[test]
fn test_matches_key_macro_with_alt_keybinding() {
let alt_key = Key::Char('k');
let key = Key::Up;
assert!(matches_key!(up, key));
assert!(matches_key!(up, alt_key));
assert!(!matches_key!(up, Key::Char('t')));
}
#[test]
fn test_matches_key_macro_with_alt_keybinding_uses_alt_key_when_ignore_special_keys_is_false() {
let alt_key = Key::Char('k');
let key = Key::Up;
assert!(matches_key!(up, key, false));
assert!(matches_key!(up, alt_key, false));
assert!(!matches_key!(up, Key::Char('t'), false));
}
#[test]
fn test_matches_key_macro_with_alt_keybinding_ignores_alt_key_when_ignore_special_keys_is_true() {
let alt_key = Key::Char('k');
let key = Key::Up;
assert!(matches_key!(up, key, true));
assert!(!matches_key!(up, alt_key, true));
assert!(!matches_key!(up, Key::Char('t'), true));
}
} }
+2 -2
View File
@@ -39,7 +39,7 @@ pub struct App<'a> {
pub is_routing: bool, pub is_routing: bool,
pub is_loading: bool, pub is_loading: bool,
pub should_refresh: bool, pub should_refresh: bool,
pub should_ignore_quit_key: bool, pub ignore_special_keys_for_textbox_input: bool,
pub cli_mode: bool, pub cli_mode: bool,
pub data: Data<'a>, pub data: Data<'a>,
} }
@@ -224,7 +224,7 @@ impl Default for App<'_> {
is_loading: false, is_loading: false,
is_routing: false, is_routing: false,
should_refresh: false, should_refresh: false,
should_ignore_quit_key: false, ignore_special_keys_for_textbox_input: false,
cli_mode: false, cli_mode: false,
data: Data::default(), data: Data::default(),
} }
+5 -5
View File
@@ -22,12 +22,12 @@ pub trait KeyEventHandler<'a, 'b, T: Into<Route> + Copy> {
fn handle_key_event(&mut self) { fn handle_key_event(&mut self) {
let key = self.get_key(); let key = self.get_key();
match key { match key {
_ if matches_key!(up, key, self.ignore_alt_navigation()) => { _ if matches_key!(up, key, self.ignore_special_keys()) => {
if self.is_ready() { if self.is_ready() {
self.handle_scroll_up(); self.handle_scroll_up();
} }
} }
_ if matches_key!(down, key, self.ignore_alt_navigation()) => { _ if matches_key!(down, key, self.ignore_special_keys()) => {
if self.is_ready() { if self.is_ready() {
self.handle_scroll_down(); self.handle_scroll_down();
} }
@@ -47,8 +47,8 @@ pub trait KeyEventHandler<'a, 'b, T: Into<Route> + Copy> {
self.handle_delete(); self.handle_delete();
} }
} }
_ if matches_key!(left, key, self.ignore_alt_navigation()) _ if matches_key!(left, key, self.ignore_special_keys())
|| matches_key!(right, key, self.ignore_alt_navigation()) => || matches_key!(right, key, self.ignore_special_keys()) =>
{ {
self.handle_left_right_action() self.handle_left_right_action()
} }
@@ -73,7 +73,7 @@ pub trait KeyEventHandler<'a, 'b, T: Into<Route> + Copy> {
fn accepts(active_block: T) -> bool; fn accepts(active_block: T) -> bool;
fn new(key: Key, app: &'a mut App<'b>, active_block: T, context: Option<T>) -> Self; fn new(key: Key, app: &'a mut App<'b>, active_block: T, context: Option<T>) -> Self;
fn get_key(&self) -> Key; fn get_key(&self) -> Key;
fn ignore_alt_navigation(&self) -> bool; fn ignore_special_keys(&self) -> bool;
fn is_ready(&self) -> bool; fn is_ready(&self) -> bool;
fn handle_scroll_up(&mut self); fn handle_scroll_up(&mut self);
fn handle_scroll_down(&mut self); fn handle_scroll_down(&mut self);
@@ -543,11 +543,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_blocklist_handler_ignore_alt_navigation( fn test_blocklist_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = BlocklistHandler::new( let handler = BlocklistHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -555,7 +555,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -50,8 +50,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for BlocklistHandler<'a,
BLOCKLIST_BLOCKS.contains(&active_block) BLOCKLIST_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -45,8 +45,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionDetailsHan
COLLECTION_DETAILS_BLOCKS.contains(&active_block) COLLECTION_DETAILS_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -280,11 +280,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_collection_details_handler_ignore_alt_navigation( fn test_collection_details_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = CollectionDetailsHandler::new( let handler = CollectionDetailsHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -292,7 +292,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -590,11 +590,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_collections_handler_ignore_alt_navigation( fn test_collections_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = CollectionsHandler::new( let handler = CollectionsHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -602,7 +602,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -68,8 +68,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditCollectionHandle
EDIT_COLLECTION_BLOCKS.contains(&active_block) EDIT_COLLECTION_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -265,7 +265,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditCollectionHandle
) )
.into(), .into(),
); );
self.app.should_ignore_quit_key = true; self.app.ignore_special_keys_for_textbox_input = true;
} }
ActiveRadarrBlock::EditCollectionToggleMonitored => { ActiveRadarrBlock::EditCollectionToggleMonitored => {
self self
@@ -314,7 +314,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditCollectionHandle
| ActiveRadarrBlock::EditCollectionSelectQualityProfile => self.app.pop_navigation_stack(), | ActiveRadarrBlock::EditCollectionSelectQualityProfile => self.app.pop_navigation_stack(),
ActiveRadarrBlock::EditCollectionRootFolderPathInput => { ActiveRadarrBlock::EditCollectionRootFolderPathInput => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
_ => (), _ => (),
} }
@@ -324,7 +324,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditCollectionHandle
match self.active_radarr_block { match self.active_radarr_block {
ActiveRadarrBlock::EditCollectionRootFolderPathInput => { ActiveRadarrBlock::EditCollectionRootFolderPathInput => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
ActiveRadarrBlock::EditCollectionPrompt => { ActiveRadarrBlock::EditCollectionPrompt => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
@@ -458,7 +458,7 @@ mod tests {
#[test] #[test]
fn test_edit_collection_root_folder_path_input_submit() { fn test_edit_collection_root_folder_path_input_submit() {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.radarr_data.edit_collection_modal = Some(EditCollectionModal { app.data.radarr_data.edit_collection_modal = Some(EditCollectionModal {
path: "Test Path".into(), path: "Test Path".into(),
..EditCollectionModal::default() ..EditCollectionModal::default()
@@ -474,7 +474,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(!app assert!(!app
.data .data
.radarr_data .radarr_data
@@ -760,7 +760,7 @@ mod tests {
assert_eq!(app.data.radarr_data.prompt_confirm_action, None); assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
if selected_block == ActiveRadarrBlock::EditCollectionRootFolderPathInput { if selected_block == ActiveRadarrBlock::EditCollectionRootFolderPathInput {
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
} }
} }
@@ -792,7 +792,7 @@ mod tests {
); );
if active_radarr_block == ActiveRadarrBlock::EditCollectionRootFolderPathInput { if active_radarr_block == ActiveRadarrBlock::EditCollectionRootFolderPathInput {
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
} }
} }
} }
@@ -812,7 +812,7 @@ mod tests {
let mut app = App::test_default(); let mut app = App::test_default();
app.data.radarr_data = create_test_radarr_data(); app.data.radarr_data = create_test_radarr_data();
app.data.radarr_data.edit_collection_modal = Some(EditCollectionModal::default()); app.data.radarr_data.edit_collection_modal = Some(EditCollectionModal::default());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.push_navigation_stack(ActiveRadarrBlock::EditCollectionPrompt.into()); app.push_navigation_stack(ActiveRadarrBlock::EditCollectionPrompt.into());
app.push_navigation_stack(ActiveRadarrBlock::EditCollectionRootFolderPathInput.into()); app.push_navigation_stack(ActiveRadarrBlock::EditCollectionRootFolderPathInput.into());
@@ -824,7 +824,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app.get_current_route(), app.get_current_route(),
ActiveRadarrBlock::EditCollectionPrompt.into() ActiveRadarrBlock::EditCollectionPrompt.into()
@@ -1021,11 +1021,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_edit_collection_handler_ignore_alt_navigation( fn test_edit_collection_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = EditCollectionHandler::new( let handler = EditCollectionHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -1033,7 +1033,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -72,8 +72,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'
|| COLLECTIONS_BLOCKS.contains(&active_block) || COLLECTIONS_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -389,11 +389,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_downloads_handler_ignore_alt_navigation( fn test_downloads_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = DownloadsHandler::new( let handler = DownloadsHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -401,7 +401,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -46,8 +46,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DownloadsHandler<'a,
DOWNLOADS_BLOCKS.contains(&active_block) DOWNLOADS_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -66,8 +66,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditIndexerHandler<'
EDIT_INDEXER_BLOCKS.contains(&active_block) EDIT_INDEXER_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -361,7 +361,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditIndexerHandler<'
| ActiveRadarrBlock::EditIndexerSeedRatioInput | ActiveRadarrBlock::EditIndexerSeedRatioInput
| ActiveRadarrBlock::EditIndexerTagsInput => { | ActiveRadarrBlock::EditIndexerTagsInput => {
self.app.push_navigation_stack(selected_block.into()); self.app.push_navigation_stack(selected_block.into());
self.app.should_ignore_quit_key = true; self.app.ignore_special_keys_for_textbox_input = true;
} }
ActiveRadarrBlock::EditIndexerPriorityInput => self ActiveRadarrBlock::EditIndexerPriorityInput => self
.app .app
@@ -407,7 +407,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditIndexerHandler<'
| ActiveRadarrBlock::EditIndexerSeedRatioInput | ActiveRadarrBlock::EditIndexerSeedRatioInput
| ActiveRadarrBlock::EditIndexerTagsInput => { | ActiveRadarrBlock::EditIndexerTagsInput => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
ActiveRadarrBlock::EditIndexerPriorityInput => self.app.pop_navigation_stack(), ActiveRadarrBlock::EditIndexerPriorityInput => self.app.pop_navigation_stack(),
_ => (), _ => (),
@@ -428,7 +428,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditIndexerHandler<'
| ActiveRadarrBlock::EditIndexerPriorityInput | ActiveRadarrBlock::EditIndexerPriorityInput
| ActiveRadarrBlock::EditIndexerTagsInput => { | ActiveRadarrBlock::EditIndexerTagsInput => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
_ => self.app.pop_navigation_stack(), _ => self.app.pop_navigation_stack(),
} }
@@ -1003,7 +1003,7 @@ mod tests {
.handle(); .handle();
assert_eq!(app.get_current_route(), block.into()); assert_eq!(app.get_current_route(), block.into());
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
} }
#[test] #[test]
@@ -1028,7 +1028,7 @@ mod tests {
app.get_current_route(), app.get_current_route(),
ActiveRadarrBlock::EditIndexerPriorityInput.into() ActiveRadarrBlock::EditIndexerPriorityInput.into()
); );
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
} }
#[test] #[test]
@@ -1194,7 +1194,7 @@ mod tests {
fn test_edit_indexer_name_input_submit() { fn test_edit_indexer_name_input_submit() {
let mut app = App::test_default(); let mut app = App::test_default();
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into()); app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal { app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
name: "Test".into(), name: "Test".into(),
..EditIndexerModal::default() ..EditIndexerModal::default()
@@ -1210,7 +1210,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(!app assert!(!app
.data .data
.radarr_data .radarr_data
@@ -1230,7 +1230,7 @@ mod tests {
fn test_edit_indexer_url_input_submit() { fn test_edit_indexer_url_input_submit() {
let mut app = App::test_default(); let mut app = App::test_default();
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into()); app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal { app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
url: "Test".into(), url: "Test".into(),
..EditIndexerModal::default() ..EditIndexerModal::default()
@@ -1246,7 +1246,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(!app assert!(!app
.data .data
.radarr_data .radarr_data
@@ -1266,7 +1266,7 @@ mod tests {
fn test_edit_indexer_api_key_input_submit() { fn test_edit_indexer_api_key_input_submit() {
let mut app = App::test_default(); let mut app = App::test_default();
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into()); app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal { app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
api_key: "Test".into(), api_key: "Test".into(),
..EditIndexerModal::default() ..EditIndexerModal::default()
@@ -1282,7 +1282,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(!app assert!(!app
.data .data
.radarr_data .radarr_data
@@ -1302,7 +1302,7 @@ mod tests {
fn test_edit_indexer_seed_ratio_input_submit() { fn test_edit_indexer_seed_ratio_input_submit() {
let mut app = App::test_default(); let mut app = App::test_default();
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into()); app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal { app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
seed_ratio: "Test".into(), seed_ratio: "Test".into(),
..EditIndexerModal::default() ..EditIndexerModal::default()
@@ -1318,7 +1318,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(!app assert!(!app
.data .data
.radarr_data .radarr_data
@@ -1338,7 +1338,7 @@ mod tests {
fn test_edit_indexer_tags_input_submit() { fn test_edit_indexer_tags_input_submit() {
let mut app = App::test_default(); let mut app = App::test_default();
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into()); app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal { app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal {
tags: "Test".into(), tags: "Test".into(),
..EditIndexerModal::default() ..EditIndexerModal::default()
@@ -1354,7 +1354,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(!app assert!(!app
.data .data
.radarr_data .radarr_data
@@ -1418,12 +1418,12 @@ mod tests {
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into()); app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
app.push_navigation_stack(active_radarr_block.into()); app.push_navigation_stack(active_radarr_block.into());
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default()); app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
EditIndexerHandler::new(ESC_KEY, &mut app, active_radarr_block, None).handle(); EditIndexerHandler::new(ESC_KEY, &mut app, active_radarr_block, None).handle();
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into()); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app.data.radarr_data.edit_indexer_modal, app.data.radarr_data.edit_indexer_modal,
Some(EditIndexerModal::default()) Some(EditIndexerModal::default())
@@ -1795,11 +1795,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_edit_indexer_handler_ignore_alt_navigation( fn test_edit_indexer_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = EditIndexerHandler::new( let handler = EditIndexerHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -1807,7 +1807,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -38,8 +38,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexerSettingsHandl
INDEXER_SETTINGS_BLOCKS.contains(&active_block) INDEXER_SETTINGS_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -212,7 +212,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexerSettingsHandl
self.app.push_navigation_stack( self.app.push_navigation_stack(
ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput.into(), ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput.into(),
); );
self.app.should_ignore_quit_key = true; self.app.ignore_special_keys_for_textbox_input = true;
} }
ActiveRadarrBlock::IndexerSettingsTogglePreferIndexerFlags => { ActiveRadarrBlock::IndexerSettingsTogglePreferIndexerFlags => {
let indexer_settings = self.app.data.radarr_data.indexer_settings.as_mut().unwrap(); let indexer_settings = self.app.data.radarr_data.indexer_settings.as_mut().unwrap();
@@ -229,7 +229,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexerSettingsHandl
} }
ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput => { ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
ActiveRadarrBlock::IndexerSettingsMinimumAgeInput ActiveRadarrBlock::IndexerSettingsMinimumAgeInput
| ActiveRadarrBlock::IndexerSettingsRetentionInput | ActiveRadarrBlock::IndexerSettingsRetentionInput
@@ -249,7 +249,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexerSettingsHandl
} }
ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput => { ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
_ => self.app.pop_navigation_stack(), _ => self.app.pop_navigation_stack(),
} }
@@ -603,7 +603,7 @@ mod tests {
app.get_current_route(), app.get_current_route(),
ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput.into() ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput.into()
); );
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
} }
#[test] #[test]
@@ -717,7 +717,7 @@ mod tests {
#[test] #[test]
fn test_edit_indexer_settings_whitelisted_subtitle_tags_input_submit() { fn test_edit_indexer_settings_whitelisted_subtitle_tags_input_submit() {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.radarr_data.indexer_settings = Some(IndexerSettings { app.data.radarr_data.indexer_settings = Some(IndexerSettings {
whitelisted_hardcoded_subs: "Test tags".into(), whitelisted_hardcoded_subs: "Test tags".into(),
..IndexerSettings::default() ..IndexerSettings::default()
@@ -735,7 +735,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(!app assert!(!app
.data .data
.radarr_data .radarr_data
@@ -815,7 +815,7 @@ mod tests {
ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput.into(), ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput.into(),
); );
app.data.radarr_data.indexer_settings = Some(IndexerSettings::default()); app.data.radarr_data.indexer_settings = Some(IndexerSettings::default());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
IndexerSettingsHandler::new( IndexerSettingsHandler::new(
ESC_KEY, ESC_KEY,
@@ -826,7 +826,7 @@ mod tests {
.handle(); .handle();
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into()); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app.data.radarr_data.indexer_settings, app.data.radarr_data.indexer_settings,
Some(IndexerSettings::default()) Some(IndexerSettings::default())
@@ -972,11 +972,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_indexer_settings_handler_ignore_alt_navigation( fn test_indexer_settings_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = IndexerSettingsHandler::new( let handler = IndexerSettingsHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -984,7 +984,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -634,11 +634,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_indexers_handler_ignore_alt_navigation( fn test_indexers_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = IndexersHandler::new( let handler = IndexersHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -646,7 +646,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
+2 -2
View File
@@ -69,8 +69,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexersHandler<'a,
|| INDEXERS_BLOCKS.contains(&active_block) || INDEXERS_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -48,8 +48,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for TestAllIndexersHandl
active_block == ActiveRadarrBlock::TestAllIndexers active_block == ActiveRadarrBlock::TestAllIndexers
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -50,11 +50,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_test_all_indexers_handler_ignore_alt_navigation( fn test_test_all_indexers_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = TestAllIndexersHandler::new( let handler = TestAllIndexersHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -62,7 +62,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -133,8 +133,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
ADD_MOVIE_BLOCKS.contains(&active_block) ADD_MOVIE_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -409,7 +409,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
self self
.app .app
.push_navigation_stack(ActiveRadarrBlock::AddMovieSearchResults.into()); .push_navigation_stack(ActiveRadarrBlock::AddMovieSearchResults.into());
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
_ if self.active_radarr_block == ActiveRadarrBlock::AddMovieSearchResults _ if self.active_radarr_block == ActiveRadarrBlock::AddMovieSearchResults
&& self.app.data.radarr_data.add_searched_movies.is_some() => && self.app.data.radarr_data.add_searched_movies.is_some() =>
@@ -473,7 +473,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
) )
.into(), .into(),
); );
self.app.should_ignore_quit_key = true; self.app.ignore_special_keys_for_textbox_input = true;
} }
_ => (), _ => (),
} }
@@ -484,7 +484,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
| ActiveRadarrBlock::AddMovieSelectRootFolder => self.app.pop_navigation_stack(), | ActiveRadarrBlock::AddMovieSelectRootFolder => self.app.pop_navigation_stack(),
ActiveRadarrBlock::AddMovieTagsInput => { ActiveRadarrBlock::AddMovieTagsInput => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
_ => (), _ => (),
} }
@@ -495,12 +495,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
ActiveRadarrBlock::AddMovieSearchInput => { ActiveRadarrBlock::AddMovieSearchInput => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.data.radarr_data.add_movie_search = None; self.app.data.radarr_data.add_movie_search = None;
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
ActiveRadarrBlock::AddMovieSearchResults | ActiveRadarrBlock::AddMovieEmptySearchResults => { ActiveRadarrBlock::AddMovieSearchResults | ActiveRadarrBlock::AddMovieEmptySearchResults => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.data.radarr_data.add_searched_movies = None; self.app.data.radarr_data.add_searched_movies = None;
self.app.should_ignore_quit_key = true; self.app.ignore_special_keys_for_textbox_input = true;
} }
ActiveRadarrBlock::AddMoviePrompt => { ActiveRadarrBlock::AddMoviePrompt => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
@@ -514,7 +514,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
| ActiveRadarrBlock::AddMovieSelectRootFolder => self.app.pop_navigation_stack(), | ActiveRadarrBlock::AddMovieSelectRootFolder => self.app.pop_navigation_stack(),
ActiveRadarrBlock::AddMovieTagsInput => { ActiveRadarrBlock::AddMovieTagsInput => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
_ => (), _ => (),
} }
@@ -782,7 +782,7 @@ mod tests {
#[test] #[test]
fn test_add_movie_search_input_submit() { fn test_add_movie_search_input_submit() {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.radarr_data.add_movie_search = Some("test".into()); app.data.radarr_data.add_movie_search = Some("test".into());
AddMovieHandler::new( AddMovieHandler::new(
@@ -793,7 +793,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app.get_current_route(), app.get_current_route(),
ActiveRadarrBlock::AddMovieSearchResults.into() ActiveRadarrBlock::AddMovieSearchResults.into()
@@ -805,7 +805,7 @@ mod tests {
let mut app = App::test_default(); let mut app = App::test_default();
app.data.radarr_data.add_movie_search = Some(HorizontallyScrollableText::default()); app.data.radarr_data.add_movie_search = Some(HorizontallyScrollableText::default());
app.push_navigation_stack(ActiveRadarrBlock::AddMovieSearchInput.into()); app.push_navigation_stack(ActiveRadarrBlock::AddMovieSearchInput.into());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
AddMovieHandler::new( AddMovieHandler::new(
SUBMIT_KEY, SUBMIT_KEY,
@@ -815,7 +815,7 @@ mod tests {
) )
.handle(); .handle();
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app.get_current_route(), app.get_current_route(),
ActiveRadarrBlock::AddMovieSearchInput.into() ActiveRadarrBlock::AddMovieSearchInput.into()
@@ -1093,7 +1093,7 @@ mod tests {
assert_eq!(app.data.radarr_data.prompt_confirm_action, None); assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
if selected_block == ActiveRadarrBlock::AddMovieTagsInput { if selected_block == ActiveRadarrBlock::AddMovieTagsInput {
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
} }
} }
@@ -1126,7 +1126,7 @@ mod tests {
); );
if active_radarr_block == ActiveRadarrBlock::AddMovieTagsInput { if active_radarr_block == ActiveRadarrBlock::AddMovieTagsInput {
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
} }
} }
} }
@@ -1149,7 +1149,7 @@ mod tests {
let mut app = App::test_default(); let mut app = App::test_default();
app.is_loading = is_ready; app.is_loading = is_ready;
app.data.radarr_data = create_test_radarr_data(); app.data.radarr_data = create_test_radarr_data();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.push_navigation_stack(ActiveRadarrBlock::AddMovieSearchInput.into()); app.push_navigation_stack(ActiveRadarrBlock::AddMovieSearchInput.into());
AddMovieHandler::new( AddMovieHandler::new(
@@ -1160,7 +1160,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into()); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
assert_eq!(app.data.radarr_data.add_movie_search, None); assert_eq!(app.data.radarr_data.add_movie_search, None);
} }
@@ -1169,7 +1169,7 @@ mod tests {
fn test_add_movie_input_esc() { fn test_add_movie_input_esc() {
let mut app = App::test_default(); let mut app = App::test_default();
app.data.radarr_data = create_test_radarr_data(); app.data.radarr_data = create_test_radarr_data();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.push_navigation_stack(ActiveRadarrBlock::AddMoviePrompt.into()); app.push_navigation_stack(ActiveRadarrBlock::AddMoviePrompt.into());
app.push_navigation_stack(ActiveRadarrBlock::AddMovieTagsInput.into()); app.push_navigation_stack(ActiveRadarrBlock::AddMovieTagsInput.into());
@@ -1181,7 +1181,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app.get_current_route(), app.get_current_route(),
ActiveRadarrBlock::AddMoviePrompt.into() ActiveRadarrBlock::AddMoviePrompt.into()
@@ -1213,7 +1213,7 @@ mod tests {
ActiveRadarrBlock::AddMovieSearchInput.into() ActiveRadarrBlock::AddMovieSearchInput.into()
); );
assert!(app.data.radarr_data.add_searched_movies.is_none()); assert!(app.data.radarr_data.add_searched_movies.is_none());
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
} }
#[test] #[test]
@@ -1259,7 +1259,7 @@ mod tests {
fn test_add_movie_tags_input_esc() { fn test_add_movie_tags_input_esc() {
let mut app = App::test_default(); let mut app = App::test_default();
app.data.radarr_data = create_test_radarr_data(); app.data.radarr_data = create_test_radarr_data();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.push_navigation_stack(ActiveRadarrBlock::AddMoviePrompt.into()); app.push_navigation_stack(ActiveRadarrBlock::AddMoviePrompt.into());
app.push_navigation_stack(ActiveRadarrBlock::AddMovieTagsInput.into()); app.push_navigation_stack(ActiveRadarrBlock::AddMovieTagsInput.into());
@@ -1271,7 +1271,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app.get_current_route(), app.get_current_route(),
ActiveRadarrBlock::AddMoviePrompt.into() ActiveRadarrBlock::AddMoviePrompt.into()
@@ -1524,11 +1524,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_add_movie_handler_ignore_alt_navigation( fn test_add_movie_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = AddMovieHandler::new( let handler = AddMovieHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -1536,7 +1536,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -37,8 +37,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DeleteMovieHandler<'
DELETE_MOVIE_BLOCKS.contains(&active_block) DELETE_MOVIE_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -315,11 +315,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_delete_movie_handler_ignore_alt_navigation( fn test_delete_movie_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = DeleteMovieHandler::new( let handler = DeleteMovieHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -327,7 +327,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -67,8 +67,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditMovieHandler<'a,
EDIT_MOVIE_BLOCKS.contains(&active_block) EDIT_MOVIE_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -293,7 +293,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditMovieHandler<'a,
) )
.into(), .into(),
); );
self.app.should_ignore_quit_key = true; self.app.ignore_special_keys_for_textbox_input = true;
} }
ActiveRadarrBlock::EditMovieToggleMonitored => { ActiveRadarrBlock::EditMovieToggleMonitored => {
self self
@@ -322,7 +322,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditMovieHandler<'a,
| ActiveRadarrBlock::EditMovieSelectQualityProfile => self.app.pop_navigation_stack(), | ActiveRadarrBlock::EditMovieSelectQualityProfile => self.app.pop_navigation_stack(),
ActiveRadarrBlock::EditMoviePathInput | ActiveRadarrBlock::EditMovieTagsInput => { ActiveRadarrBlock::EditMoviePathInput | ActiveRadarrBlock::EditMovieTagsInput => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
_ => (), _ => (),
} }
@@ -332,7 +332,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditMovieHandler<'a,
match self.active_radarr_block { match self.active_radarr_block {
ActiveRadarrBlock::EditMovieTagsInput | ActiveRadarrBlock::EditMoviePathInput => { ActiveRadarrBlock::EditMovieTagsInput | ActiveRadarrBlock::EditMoviePathInput => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
ActiveRadarrBlock::EditMoviePrompt => { ActiveRadarrBlock::EditMoviePrompt => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
@@ -549,7 +549,7 @@ mod tests {
#[test] #[test]
fn test_edit_movie_path_input_submit() { fn test_edit_movie_path_input_submit() {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.radarr_data.edit_movie_modal = Some(EditMovieModal { app.data.radarr_data.edit_movie_modal = Some(EditMovieModal {
path: "Test Path".into(), path: "Test Path".into(),
..EditMovieModal::default() ..EditMovieModal::default()
@@ -565,7 +565,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(!app assert!(!app
.data .data
.radarr_data .radarr_data
@@ -584,7 +584,7 @@ mod tests {
#[test] #[test]
fn test_edit_movie_tags_input_submit() { fn test_edit_movie_tags_input_submit() {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.radarr_data.edit_movie_modal = Some(EditMovieModal { app.data.radarr_data.edit_movie_modal = Some(EditMovieModal {
tags: "Test Tags".into(), tags: "Test Tags".into(),
..EditMovieModal::default() ..EditMovieModal::default()
@@ -600,7 +600,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(!app assert!(!app
.data .data
.radarr_data .radarr_data
@@ -814,7 +814,7 @@ mod tests {
if selected_block == ActiveRadarrBlock::EditMoviePathInput if selected_block == ActiveRadarrBlock::EditMoviePathInput
|| selected_block == ActiveRadarrBlock::EditMovieTagsInput || selected_block == ActiveRadarrBlock::EditMovieTagsInput
{ {
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
} }
} }
@@ -852,7 +852,7 @@ mod tests {
.into() .into()
); );
assert_eq!(app.data.radarr_data.prompt_confirm_action, None); assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
} }
#[rstest] #[rstest]
@@ -886,7 +886,7 @@ mod tests {
if active_radarr_block == ActiveRadarrBlock::EditMoviePathInput if active_radarr_block == ActiveRadarrBlock::EditMoviePathInput
|| active_radarr_block == ActiveRadarrBlock::EditMovieTagsInput || active_radarr_block == ActiveRadarrBlock::EditMovieTagsInput
{ {
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
} }
} }
} }
@@ -912,13 +912,13 @@ mod tests {
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.data.radarr_data = create_test_radarr_data(); app.data.radarr_data = create_test_radarr_data();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.push_navigation_stack(ActiveRadarrBlock::EditMoviePrompt.into()); app.push_navigation_stack(ActiveRadarrBlock::EditMoviePrompt.into());
app.push_navigation_stack(active_radarr_block.into()); app.push_navigation_stack(active_radarr_block.into());
EditMovieHandler::new(ESC_KEY, &mut app, active_radarr_block, None).handle(); EditMovieHandler::new(ESC_KEY, &mut app, active_radarr_block, None).handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app.get_current_route(), app.get_current_route(),
ActiveRadarrBlock::EditMoviePrompt.into() ActiveRadarrBlock::EditMoviePrompt.into()
@@ -1150,11 +1150,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_edit_movie_handler_ignore_alt_navigation( fn test_edit_movie_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = EditMovieHandler::new( let handler = EditMovieHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -1162,7 +1162,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -331,7 +331,7 @@ mod tests {
app.get_current_route(), app.get_current_route(),
ActiveRadarrBlock::AddMovieSearchInput.into() ActiveRadarrBlock::AddMovieSearchInput.into()
); );
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
assert!(app.data.radarr_data.add_movie_search.is_some()); assert!(app.data.radarr_data.add_movie_search.is_some());
} }
@@ -355,7 +355,7 @@ mod tests {
.handle(); .handle();
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into()); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(app.data.radarr_data.add_movie_search.is_none()); assert!(app.data.radarr_data.add_movie_search.is_none());
} }
@@ -778,11 +778,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_library_handler_ignore_alt_navigation( fn test_library_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = LibraryHandler::new( let handler = LibraryHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -790,7 +790,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
+3 -3
View File
@@ -80,8 +80,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
|| LIBRARY_BLOCKS.contains(&active_block) || LIBRARY_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -181,7 +181,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
.app .app
.push_navigation_stack(ActiveRadarrBlock::AddMovieSearchInput.into()); .push_navigation_stack(ActiveRadarrBlock::AddMovieSearchInput.into());
self.app.data.radarr_data.add_movie_search = Some(HorizontallyScrollableText::default()); self.app.data.radarr_data.add_movie_search = Some(HorizontallyScrollableText::default());
self.app.should_ignore_quit_key = true; self.app.ignore_special_keys_for_textbox_input = true;
} }
_ if matches_key!(update, key) => { _ if matches_key!(update, key) => {
self self
@@ -135,8 +135,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for MovieDetailsHandler<
MOVIE_DETAILS_BLOCKS.contains(&active_block) MOVIE_DETAILS_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -1043,11 +1043,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_movie_details_handler_ignore_alt_navigation( fn test_movie_details_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = MovieDetailsHandler::new( let handler = MovieDetailsHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -1055,7 +1055,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[rstest] #[rstest]
+6 -6
View File
@@ -64,8 +64,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RadarrHandler<'a, 'b
true true
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -112,11 +112,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RadarrHandler<'a, 'b
pub fn handle_change_tab_left_right_keys(app: &mut App<'_>, key: Key) { pub fn handle_change_tab_left_right_keys(app: &mut App<'_>, key: Key) {
let key_ref = key; let key_ref = key;
match key_ref { match key_ref {
_ if matches_key!(left, key, app.should_ignore_quit_key) => { _ if matches_key!(left, key, app.ignore_special_keys_for_textbox_input) => {
app.data.radarr_data.main_tabs.previous(); app.data.radarr_data.main_tabs.previous();
app.pop_and_push_navigation_stack(app.data.radarr_data.main_tabs.get_active_route()); app.pop_and_push_navigation_stack(app.data.radarr_data.main_tabs.get_active_route());
} }
_ if matches_key!(right, key, app.should_ignore_quit_key) => { _ if matches_key!(right, key, app.ignore_special_keys_for_textbox_input) => {
app.data.radarr_data.main_tabs.next(); app.data.radarr_data.main_tabs.next();
app.pop_and_push_navigation_stack(app.data.radarr_data.main_tabs.get_active_route()); app.pop_and_push_navigation_stack(app.data.radarr_data.main_tabs.get_active_route());
} }
@@ -142,7 +142,7 @@ macro_rules! search_table {
}; };
$app.data.radarr_data.is_searching = false; $app.data.radarr_data.is_searching = false;
$app.should_ignore_quit_key = false; $app.ignore_special_keys_for_textbox_input = false;
if search_index.is_some() { if search_index.is_some() {
$app.pop_navigation_stack(); $app.pop_navigation_stack();
@@ -169,7 +169,7 @@ macro_rules! search_table {
}; };
$app.data.radarr_data.is_searching = false; $app.data.radarr_data.is_searching = false;
$app.should_ignore_quit_key = false; $app.ignore_special_keys_for_textbox_input = false;
if search_index.is_some() { if search_index.is_some() {
$app.pop_navigation_stack(); $app.pop_navigation_stack();
@@ -60,7 +60,7 @@ mod tests {
#[case] right_block: ActiveRadarrBlock, #[case] right_block: ActiveRadarrBlock,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = false; app.ignore_special_keys_for_textbox_input = false;
app.data.radarr_data.main_tabs.set_index(index); app.data.radarr_data.main_tabs.set_index(index);
handle_change_tab_left_right_keys(&mut app, DEFAULT_KEYBINDINGS.left.alt.unwrap()); handle_change_tab_left_right_keys(&mut app, DEFAULT_KEYBINDINGS.left.alt.unwrap());
@@ -95,7 +95,7 @@ mod tests {
#[case] block: ActiveRadarrBlock, #[case] block: ActiveRadarrBlock,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.push_navigation_stack(block.into()); app.push_navigation_stack(block.into());
app.data.radarr_data.main_tabs.set_index(index); app.data.radarr_data.main_tabs.set_index(index);
@@ -288,11 +288,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_radarr_handler_ignore_alt_navigation( fn test_radarr_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = RadarrHandler::new( let handler = RadarrHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -300,7 +300,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -69,8 +69,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RootFoldersHandler<'
ROOT_FOLDERS_BLOCKS.contains(&active_block) ROOT_FOLDERS_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -173,7 +173,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RootFoldersHandler<'
self.build_add_root_folder_body(), self.build_add_root_folder_body(),
)); ));
self.app.data.radarr_data.prompt_confirm = true; self.app.data.radarr_data.prompt_confirm = true;
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
} }
_ => (), _ => (),
@@ -186,7 +186,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RootFoldersHandler<'
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.data.radarr_data.edit_root_folder = None; self.app.data.radarr_data.edit_root_folder = None;
self.app.data.radarr_data.prompt_confirm = false; self.app.data.radarr_data.prompt_confirm = false;
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
ActiveRadarrBlock::DeleteRootFolderPrompt => { ActiveRadarrBlock::DeleteRootFolderPrompt => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
@@ -208,7 +208,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RootFoldersHandler<'
.app .app
.push_navigation_stack(ActiveRadarrBlock::AddRootFolderPrompt.into()); .push_navigation_stack(ActiveRadarrBlock::AddRootFolderPrompt.into());
self.app.data.radarr_data.edit_root_folder = Some(HorizontallyScrollableText::default()); self.app.data.radarr_data.edit_root_folder = Some(HorizontallyScrollableText::default());
self.app.should_ignore_quit_key = true; self.app.ignore_special_keys_for_textbox_input = true;
} }
_ => (), _ => (),
}, },
@@ -263,7 +263,7 @@ mod tests {
.set_items(vec![RootFolder::default()]); .set_items(vec![RootFolder::default()]);
app.data.radarr_data.edit_root_folder = Some("Test".into()); app.data.radarr_data.edit_root_folder = Some("Test".into());
app.data.radarr_data.prompt_confirm = true; app.data.radarr_data.prompt_confirm = true;
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.push_navigation_stack(ActiveRadarrBlock::RootFolders.into()); app.push_navigation_stack(ActiveRadarrBlock::RootFolders.into());
app.push_navigation_stack(ActiveRadarrBlock::AddRootFolderPrompt.into()); app.push_navigation_stack(ActiveRadarrBlock::AddRootFolderPrompt.into());
@@ -276,7 +276,7 @@ mod tests {
.handle(); .handle();
assert!(app.data.radarr_data.prompt_confirm); assert!(app.data.radarr_data.prompt_confirm);
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app.data.radarr_data.prompt_confirm_action, app.data.radarr_data.prompt_confirm_action,
Some(RadarrEvent::AddRootFolder(expected_add_root_folder_body)) Some(RadarrEvent::AddRootFolder(expected_add_root_folder_body))
@@ -292,7 +292,7 @@ mod tests {
let mut app = App::test_default(); let mut app = App::test_default();
app.data.radarr_data.edit_root_folder = Some(HorizontallyScrollableText::default()); app.data.radarr_data.edit_root_folder = Some(HorizontallyScrollableText::default());
app.data.radarr_data.prompt_confirm = false; app.data.radarr_data.prompt_confirm = false;
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.push_navigation_stack(ActiveRadarrBlock::RootFolders.into()); app.push_navigation_stack(ActiveRadarrBlock::RootFolders.into());
app.push_navigation_stack(ActiveRadarrBlock::AddRootFolderPrompt.into()); app.push_navigation_stack(ActiveRadarrBlock::AddRootFolderPrompt.into());
@@ -305,7 +305,7 @@ mod tests {
.handle(); .handle();
assert!(!app.data.radarr_data.prompt_confirm); assert!(!app.data.radarr_data.prompt_confirm);
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
assert!(app.data.radarr_data.prompt_confirm_action.is_none()); assert!(app.data.radarr_data.prompt_confirm_action.is_none());
assert_eq!( assert_eq!(
app.get_current_route(), app.get_current_route(),
@@ -407,7 +407,7 @@ mod tests {
app.push_navigation_stack(ActiveRadarrBlock::RootFolders.into()); app.push_navigation_stack(ActiveRadarrBlock::RootFolders.into());
app.push_navigation_stack(ActiveRadarrBlock::AddRootFolderPrompt.into()); app.push_navigation_stack(ActiveRadarrBlock::AddRootFolderPrompt.into());
app.data.radarr_data.edit_root_folder = Some("/nfs/test".into()); app.data.radarr_data.edit_root_folder = Some("/nfs/test".into());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
RootFoldersHandler::new( RootFoldersHandler::new(
ESC_KEY, ESC_KEY,
@@ -424,7 +424,7 @@ mod tests {
assert!(app.data.radarr_data.edit_root_folder.is_none()); assert!(app.data.radarr_data.edit_root_folder.is_none());
assert!(!app.data.radarr_data.prompt_confirm); assert!(!app.data.radarr_data.prompt_confirm);
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
} }
#[rstest] #[rstest]
@@ -473,7 +473,7 @@ mod tests {
app.get_current_route(), app.get_current_route(),
ActiveRadarrBlock::AddRootFolderPrompt.into() ActiveRadarrBlock::AddRootFolderPrompt.into()
); );
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
assert!(app.data.radarr_data.edit_root_folder.is_some()); assert!(app.data.radarr_data.edit_root_folder.is_some());
} }
@@ -500,7 +500,7 @@ mod tests {
app.get_current_route(), app.get_current_route(),
ActiveRadarrBlock::RootFolders.into() ActiveRadarrBlock::RootFolders.into()
); );
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(app.data.radarr_data.edit_root_folder.is_none()); assert!(app.data.radarr_data.edit_root_folder.is_none());
} }
@@ -646,11 +646,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_root_folders_handler_ignore_alt_navigation( fn test_root_folders_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = RootFoldersHandler::new( let handler = RootFoldersHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -658,7 +658,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
+2 -2
View File
@@ -35,8 +35,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemHandler<'a, 'b
SystemDetailsHandler::accepts(active_block) || active_block == ActiveRadarrBlock::System SystemDetailsHandler::accepts(active_block) || active_block == ActiveRadarrBlock::System
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -36,8 +36,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemDetailsHandler
SYSTEM_DETAILS_BLOCKS.contains(&active_block) SYSTEM_DETAILS_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -940,11 +940,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_system_details_handler_ignore_alt_navigation( fn test_system_details_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = SystemDetailsHandler::new( let handler = SystemDetailsHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -952,7 +952,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -451,11 +451,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_system_handler_ignore_alt_navigation( fn test_system_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = SystemHandler::new( let handler = SystemHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -463,7 +463,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -515,11 +515,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_blocklist_handler_ignore_alt_navigation( fn test_blocklist_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = BlocklistHandler::new( let handler = BlocklistHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -527,7 +527,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -50,8 +50,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for BlocklistHandler<'a,
BLOCKLIST_BLOCKS.contains(&active_block) BLOCKLIST_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -391,11 +391,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_downloads_handler_ignore_alt_navigation( fn test_downloads_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = DownloadsHandler::new( let handler = DownloadsHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -403,7 +403,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -46,8 +46,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for DownloadsHandler<'a,
DOWNLOADS_BLOCKS.contains(&active_block) DOWNLOADS_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -308,11 +308,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_history_handler_ignore_alt_navigation( fn test_history_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = HistoryHandler::new( let handler = HistoryHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -320,7 +320,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
+2 -2
View File
@@ -51,8 +51,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for HistoryHandler<'a, '
HISTORY_BLOCKS.contains(&active_block) HISTORY_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -65,8 +65,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EditIndexerHandler<'
EDIT_INDEXER_BLOCKS.contains(&active_block) EDIT_INDEXER_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -360,7 +360,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EditIndexerHandler<'
| ActiveSonarrBlock::EditIndexerSeedRatioInput | ActiveSonarrBlock::EditIndexerSeedRatioInput
| ActiveSonarrBlock::EditIndexerTagsInput => { | ActiveSonarrBlock::EditIndexerTagsInput => {
self.app.push_navigation_stack(selected_block.into()); self.app.push_navigation_stack(selected_block.into());
self.app.should_ignore_quit_key = true; self.app.ignore_special_keys_for_textbox_input = true;
} }
ActiveSonarrBlock::EditIndexerPriorityInput => self ActiveSonarrBlock::EditIndexerPriorityInput => self
.app .app
@@ -406,7 +406,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EditIndexerHandler<'
| ActiveSonarrBlock::EditIndexerSeedRatioInput | ActiveSonarrBlock::EditIndexerSeedRatioInput
| ActiveSonarrBlock::EditIndexerTagsInput => { | ActiveSonarrBlock::EditIndexerTagsInput => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
ActiveSonarrBlock::EditIndexerPriorityInput => self.app.pop_navigation_stack(), ActiveSonarrBlock::EditIndexerPriorityInput => self.app.pop_navigation_stack(),
_ => (), _ => (),
@@ -427,7 +427,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EditIndexerHandler<'
| ActiveSonarrBlock::EditIndexerPriorityInput | ActiveSonarrBlock::EditIndexerPriorityInput
| ActiveSonarrBlock::EditIndexerTagsInput => { | ActiveSonarrBlock::EditIndexerTagsInput => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
_ => self.app.pop_navigation_stack(), _ => self.app.pop_navigation_stack(),
} }
@@ -1003,7 +1003,7 @@ mod tests {
.handle(); .handle();
assert_eq!(app.get_current_route(), block.into()); assert_eq!(app.get_current_route(), block.into());
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
} }
#[test] #[test]
@@ -1028,7 +1028,7 @@ mod tests {
app.get_current_route(), app.get_current_route(),
ActiveSonarrBlock::EditIndexerPriorityInput.into() ActiveSonarrBlock::EditIndexerPriorityInput.into()
); );
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
} }
#[test] #[test]
@@ -1194,7 +1194,7 @@ mod tests {
fn test_edit_indexer_name_input_submit() { fn test_edit_indexer_name_input_submit() {
let mut app = App::test_default(); let mut app = App::test_default();
app.push_navigation_stack(ActiveSonarrBlock::Indexers.into()); app.push_navigation_stack(ActiveSonarrBlock::Indexers.into());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal { app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal {
name: "Test".into(), name: "Test".into(),
..EditIndexerModal::default() ..EditIndexerModal::default()
@@ -1210,7 +1210,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(!app assert!(!app
.data .data
.sonarr_data .sonarr_data
@@ -1230,7 +1230,7 @@ mod tests {
fn test_edit_indexer_url_input_submit() { fn test_edit_indexer_url_input_submit() {
let mut app = App::test_default(); let mut app = App::test_default();
app.push_navigation_stack(ActiveSonarrBlock::Indexers.into()); app.push_navigation_stack(ActiveSonarrBlock::Indexers.into());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal { app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal {
url: "Test".into(), url: "Test".into(),
..EditIndexerModal::default() ..EditIndexerModal::default()
@@ -1246,7 +1246,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(!app assert!(!app
.data .data
.sonarr_data .sonarr_data
@@ -1266,7 +1266,7 @@ mod tests {
fn test_edit_indexer_api_key_input_submit() { fn test_edit_indexer_api_key_input_submit() {
let mut app = App::test_default(); let mut app = App::test_default();
app.push_navigation_stack(ActiveSonarrBlock::Indexers.into()); app.push_navigation_stack(ActiveSonarrBlock::Indexers.into());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal { app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal {
api_key: "Test".into(), api_key: "Test".into(),
..EditIndexerModal::default() ..EditIndexerModal::default()
@@ -1282,7 +1282,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(!app assert!(!app
.data .data
.sonarr_data .sonarr_data
@@ -1302,7 +1302,7 @@ mod tests {
fn test_edit_indexer_seed_ratio_input_submit() { fn test_edit_indexer_seed_ratio_input_submit() {
let mut app = App::test_default(); let mut app = App::test_default();
app.push_navigation_stack(ActiveSonarrBlock::Indexers.into()); app.push_navigation_stack(ActiveSonarrBlock::Indexers.into());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal { app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal {
seed_ratio: "Test".into(), seed_ratio: "Test".into(),
..EditIndexerModal::default() ..EditIndexerModal::default()
@@ -1318,7 +1318,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(!app assert!(!app
.data .data
.sonarr_data .sonarr_data
@@ -1338,7 +1338,7 @@ mod tests {
fn test_edit_indexer_tags_input_submit() { fn test_edit_indexer_tags_input_submit() {
let mut app = App::test_default(); let mut app = App::test_default();
app.push_navigation_stack(ActiveSonarrBlock::Indexers.into()); app.push_navigation_stack(ActiveSonarrBlock::Indexers.into());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal { app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal {
tags: "Test".into(), tags: "Test".into(),
..EditIndexerModal::default() ..EditIndexerModal::default()
@@ -1354,7 +1354,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(!app assert!(!app
.data .data
.sonarr_data .sonarr_data
@@ -1418,12 +1418,12 @@ mod tests {
app.push_navigation_stack(ActiveSonarrBlock::Indexers.into()); app.push_navigation_stack(ActiveSonarrBlock::Indexers.into());
app.push_navigation_stack(active_sonarr_block.into()); app.push_navigation_stack(active_sonarr_block.into());
app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal::default()); app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
EditIndexerHandler::new(ESC_KEY, &mut app, active_sonarr_block, None).handle(); EditIndexerHandler::new(ESC_KEY, &mut app, active_sonarr_block, None).handle();
assert_eq!(app.get_current_route(), ActiveSonarrBlock::Indexers.into()); assert_eq!(app.get_current_route(), ActiveSonarrBlock::Indexers.into());
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app.data.sonarr_data.edit_indexer_modal, app.data.sonarr_data.edit_indexer_modal,
Some(EditIndexerModal::default()) Some(EditIndexerModal::default())
@@ -1795,11 +1795,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_edit_indexer_handler_ignore_alt_navigation( fn test_edit_indexer_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = EditIndexerHandler::new( let handler = EditIndexerHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -1807,7 +1807,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -36,8 +36,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for IndexerSettingsHandl
INDEXER_SETTINGS_BLOCKS.contains(&active_block) INDEXER_SETTINGS_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -523,11 +523,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_indexer_settings_handler_ignore_alt_navigation( fn test_indexer_settings_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = IndexerSettingsHandler::new( let handler = IndexerSettingsHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -535,7 +535,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -644,11 +644,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_indexers_handler_ignore_alt_navigation( fn test_indexers_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = IndexersHandler::new( let handler = IndexersHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -656,7 +656,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
+2 -2
View File
@@ -69,8 +69,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for IndexersHandler<'a,
|| INDEXERS_BLOCKS.contains(&active_block) || INDEXERS_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -48,8 +48,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for TestAllIndexersHandl
active_block == ActiveSonarrBlock::TestAllIndexers active_block == ActiveSonarrBlock::TestAllIndexers
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -50,11 +50,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_test_all_indexers_handler_ignore_alt_navigation( fn test_test_all_indexers_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = TestAllIndexersHandler::new( let handler = TestAllIndexersHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -62,7 +62,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -127,8 +127,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for AddSeriesHandler<'a,
ADD_SERIES_BLOCKS.contains(&active_block) ADD_SERIES_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -445,7 +445,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for AddSeriesHandler<'a,
self self
.app .app
.push_navigation_stack(ActiveSonarrBlock::AddSeriesSearchResults.into()); .push_navigation_stack(ActiveSonarrBlock::AddSeriesSearchResults.into());
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
_ if self.active_sonarr_block == ActiveSonarrBlock::AddSeriesSearchResults _ if self.active_sonarr_block == ActiveSonarrBlock::AddSeriesSearchResults
&& self.app.data.sonarr_data.add_searched_series.is_some() => && self.app.data.sonarr_data.add_searched_series.is_some() =>
@@ -514,7 +514,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for AddSeriesHandler<'a,
.get_active_block() .get_active_block()
.into(), .into(),
); );
self.app.should_ignore_quit_key = true; self.app.ignore_special_keys_for_textbox_input = true;
} }
ActiveSonarrBlock::AddSeriesToggleUseSeasonFolder => { ActiveSonarrBlock::AddSeriesToggleUseSeasonFolder => {
self self
@@ -543,7 +543,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for AddSeriesHandler<'a,
| ActiveSonarrBlock::AddSeriesSelectRootFolder => self.app.pop_navigation_stack(), | ActiveSonarrBlock::AddSeriesSelectRootFolder => self.app.pop_navigation_stack(),
ActiveSonarrBlock::AddSeriesTagsInput => { ActiveSonarrBlock::AddSeriesTagsInput => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
_ => (), _ => (),
} }
@@ -554,13 +554,13 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for AddSeriesHandler<'a,
ActiveSonarrBlock::AddSeriesSearchInput => { ActiveSonarrBlock::AddSeriesSearchInput => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.data.sonarr_data.add_series_search = None; self.app.data.sonarr_data.add_series_search = None;
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
ActiveSonarrBlock::AddSeriesSearchResults ActiveSonarrBlock::AddSeriesSearchResults
| ActiveSonarrBlock::AddSeriesEmptySearchResults => { | ActiveSonarrBlock::AddSeriesEmptySearchResults => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.data.sonarr_data.add_searched_series = None; self.app.data.sonarr_data.add_searched_series = None;
self.app.should_ignore_quit_key = true; self.app.ignore_special_keys_for_textbox_input = true;
} }
ActiveSonarrBlock::AddSeriesPrompt => { ActiveSonarrBlock::AddSeriesPrompt => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
@@ -575,7 +575,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for AddSeriesHandler<'a,
| ActiveSonarrBlock::AddSeriesSelectRootFolder => self.app.pop_navigation_stack(), | ActiveSonarrBlock::AddSeriesSelectRootFolder => self.app.pop_navigation_stack(),
ActiveSonarrBlock::AddSeriesTagsInput => { ActiveSonarrBlock::AddSeriesTagsInput => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
_ => (), _ => (),
} }
@@ -913,7 +913,7 @@ mod tests {
fn test_add_series_search_input_submit() { fn test_add_series_search_input_submit() {
let mut app = App::test_default(); let mut app = App::test_default();
app.push_navigation_stack(ActiveSonarrBlock::Series.into()); app.push_navigation_stack(ActiveSonarrBlock::Series.into());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.sonarr_data.add_series_search = Some("test".into()); app.data.sonarr_data.add_series_search = Some("test".into());
AddSeriesHandler::new( AddSeriesHandler::new(
@@ -924,7 +924,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app.get_current_route(), app.get_current_route(),
ActiveSonarrBlock::AddSeriesSearchResults.into() ActiveSonarrBlock::AddSeriesSearchResults.into()
@@ -937,7 +937,7 @@ mod tests {
app.data.sonarr_data.add_series_search = Some(HorizontallyScrollableText::default()); app.data.sonarr_data.add_series_search = Some(HorizontallyScrollableText::default());
app.push_navigation_stack(ActiveSonarrBlock::Series.into()); app.push_navigation_stack(ActiveSonarrBlock::Series.into());
app.push_navigation_stack(ActiveSonarrBlock::AddSeriesSearchInput.into()); app.push_navigation_stack(ActiveSonarrBlock::AddSeriesSearchInput.into());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
AddSeriesHandler::new( AddSeriesHandler::new(
SUBMIT_KEY, SUBMIT_KEY,
@@ -947,7 +947,7 @@ mod tests {
) )
.handle(); .handle();
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app.get_current_route(), app.get_current_route(),
ActiveSonarrBlock::AddSeriesSearchInput.into() ActiveSonarrBlock::AddSeriesSearchInput.into()
@@ -1231,7 +1231,7 @@ mod tests {
assert_eq!(app.data.sonarr_data.prompt_confirm_action, None); assert_eq!(app.data.sonarr_data.prompt_confirm_action, None);
if selected_block == ActiveSonarrBlock::AddSeriesTagsInput { if selected_block == ActiveSonarrBlock::AddSeriesTagsInput {
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
} }
} }
@@ -1260,7 +1260,7 @@ mod tests {
); );
if active_sonarr_block == ActiveSonarrBlock::AddSeriesTagsInput { if active_sonarr_block == ActiveSonarrBlock::AddSeriesTagsInput {
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
} }
} }
@@ -1337,7 +1337,7 @@ mod tests {
let mut app = App::test_default(); let mut app = App::test_default();
app.is_loading = is_ready; app.is_loading = is_ready;
app.data.sonarr_data = create_test_sonarr_data(); app.data.sonarr_data = create_test_sonarr_data();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.push_navigation_stack(ActiveSonarrBlock::Series.into()); app.push_navigation_stack(ActiveSonarrBlock::Series.into());
app.push_navigation_stack(ActiveSonarrBlock::AddSeriesSearchInput.into()); app.push_navigation_stack(ActiveSonarrBlock::AddSeriesSearchInput.into());
@@ -1349,7 +1349,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!(app.get_current_route(), ActiveSonarrBlock::Series.into()); assert_eq!(app.get_current_route(), ActiveSonarrBlock::Series.into());
assert_eq!(app.data.sonarr_data.add_series_search, None); assert_eq!(app.data.sonarr_data.add_series_search, None);
} }
@@ -1358,7 +1358,7 @@ mod tests {
fn test_add_series_input_esc() { fn test_add_series_input_esc() {
let mut app = App::test_default(); let mut app = App::test_default();
app.data.sonarr_data = create_test_sonarr_data(); app.data.sonarr_data = create_test_sonarr_data();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.push_navigation_stack(ActiveSonarrBlock::Series.into()); app.push_navigation_stack(ActiveSonarrBlock::Series.into());
app.push_navigation_stack(ActiveSonarrBlock::AddSeriesPrompt.into()); app.push_navigation_stack(ActiveSonarrBlock::AddSeriesPrompt.into());
app.push_navigation_stack(ActiveSonarrBlock::AddSeriesTagsInput.into()); app.push_navigation_stack(ActiveSonarrBlock::AddSeriesTagsInput.into());
@@ -1371,7 +1371,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app.get_current_route(), app.get_current_route(),
ActiveSonarrBlock::AddSeriesPrompt.into() ActiveSonarrBlock::AddSeriesPrompt.into()
@@ -1404,7 +1404,7 @@ mod tests {
ActiveSonarrBlock::AddSeriesSearchInput.into() ActiveSonarrBlock::AddSeriesSearchInput.into()
); );
assert!(app.data.sonarr_data.add_searched_series.is_none()); assert!(app.data.sonarr_data.add_searched_series.is_none());
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
} }
#[test] #[test]
@@ -1452,7 +1452,7 @@ mod tests {
fn test_add_series_tags_input_esc() { fn test_add_series_tags_input_esc() {
let mut app = App::test_default(); let mut app = App::test_default();
app.data.sonarr_data = create_test_sonarr_data(); app.data.sonarr_data = create_test_sonarr_data();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.push_navigation_stack(ActiveSonarrBlock::Series.into()); app.push_navigation_stack(ActiveSonarrBlock::Series.into());
app.push_navigation_stack(ActiveSonarrBlock::AddSeriesPrompt.into()); app.push_navigation_stack(ActiveSonarrBlock::AddSeriesPrompt.into());
app.push_navigation_stack(ActiveSonarrBlock::AddSeriesTagsInput.into()); app.push_navigation_stack(ActiveSonarrBlock::AddSeriesTagsInput.into());
@@ -1465,7 +1465,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app.get_current_route(), app.get_current_route(),
ActiveSonarrBlock::AddSeriesPrompt.into() ActiveSonarrBlock::AddSeriesPrompt.into()
@@ -1716,11 +1716,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_add_series_handler_ignore_alt_navigation( fn test_add_series_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = AddSeriesHandler::new( let handler = AddSeriesHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -1728,7 +1728,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -39,8 +39,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for DeleteSeriesHandler<
DELETE_SERIES_BLOCKS.contains(&active_block) DELETE_SERIES_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -322,11 +322,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_delete_series_handler_ignore_alt_navigation( fn test_delete_series_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = DeleteSeriesHandler::new( let handler = DeleteSeriesHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -334,7 +334,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -82,8 +82,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EditSeriesHandler<'a
EDIT_SERIES_BLOCKS.contains(&active_block) EDIT_SERIES_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -345,7 +345,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EditSeriesHandler<'a
) )
.into(), .into(),
); );
self.app.should_ignore_quit_key = true; self.app.ignore_special_keys_for_textbox_input = true;
} }
ActiveSonarrBlock::EditSeriesToggleMonitored => { ActiveSonarrBlock::EditSeriesToggleMonitored => {
self self
@@ -395,7 +395,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EditSeriesHandler<'a
| ActiveSonarrBlock::EditSeriesSelectLanguageProfile => self.app.pop_navigation_stack(), | ActiveSonarrBlock::EditSeriesSelectLanguageProfile => self.app.pop_navigation_stack(),
ActiveSonarrBlock::EditSeriesPathInput | ActiveSonarrBlock::EditSeriesTagsInput => { ActiveSonarrBlock::EditSeriesPathInput | ActiveSonarrBlock::EditSeriesTagsInput => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
_ => (), _ => (),
} }
@@ -405,7 +405,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EditSeriesHandler<'a
match self.active_sonarr_block { match self.active_sonarr_block {
ActiveSonarrBlock::EditSeriesTagsInput | ActiveSonarrBlock::EditSeriesPathInput => { ActiveSonarrBlock::EditSeriesTagsInput | ActiveSonarrBlock::EditSeriesPathInput => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
ActiveSonarrBlock::EditSeriesPrompt => { ActiveSonarrBlock::EditSeriesPrompt => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
@@ -678,7 +678,7 @@ mod tests {
#[test] #[test]
fn test_edit_series_path_input_submit() { fn test_edit_series_path_input_submit() {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.sonarr_data.edit_series_modal = Some(EditSeriesModal { app.data.sonarr_data.edit_series_modal = Some(EditSeriesModal {
path: "Test Path".into(), path: "Test Path".into(),
..EditSeriesModal::default() ..EditSeriesModal::default()
@@ -695,7 +695,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(!app assert!(!app
.data .data
.sonarr_data .sonarr_data
@@ -714,7 +714,7 @@ mod tests {
#[test] #[test]
fn test_edit_series_tags_input_submit() { fn test_edit_series_tags_input_submit() {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.sonarr_data.edit_series_modal = Some(EditSeriesModal { app.data.sonarr_data.edit_series_modal = Some(EditSeriesModal {
tags: "Test Tags".into(), tags: "Test Tags".into(),
..EditSeriesModal::default() ..EditSeriesModal::default()
@@ -731,7 +731,7 @@ mod tests {
) )
.handle(); .handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(!app assert!(!app
.data .data
.sonarr_data .sonarr_data
@@ -1011,7 +1011,7 @@ mod tests {
if selected_block == ActiveSonarrBlock::EditSeriesPathInput if selected_block == ActiveSonarrBlock::EditSeriesPathInput
|| selected_block == ActiveSonarrBlock::EditSeriesTagsInput || selected_block == ActiveSonarrBlock::EditSeriesTagsInput
{ {
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
} }
} }
@@ -1050,7 +1050,7 @@ mod tests {
.into() .into()
); );
assert_eq!(app.data.sonarr_data.prompt_confirm_action, None); assert_eq!(app.data.sonarr_data.prompt_confirm_action, None);
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
} }
#[rstest] #[rstest]
@@ -1086,7 +1086,7 @@ mod tests {
if active_sonarr_block == ActiveSonarrBlock::EditSeriesPathInput if active_sonarr_block == ActiveSonarrBlock::EditSeriesPathInput
|| active_sonarr_block == ActiveSonarrBlock::EditSeriesTagsInput || active_sonarr_block == ActiveSonarrBlock::EditSeriesTagsInput
{ {
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
} }
} }
} }
@@ -1112,14 +1112,14 @@ mod tests {
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.data.sonarr_data = create_test_sonarr_data(); app.data.sonarr_data = create_test_sonarr_data();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.push_navigation_stack(ActiveSonarrBlock::Series.into()); app.push_navigation_stack(ActiveSonarrBlock::Series.into());
app.push_navigation_stack(ActiveSonarrBlock::EditSeriesPrompt.into()); app.push_navigation_stack(ActiveSonarrBlock::EditSeriesPrompt.into());
app.push_navigation_stack(active_sonarr_block.into()); app.push_navigation_stack(active_sonarr_block.into());
EditSeriesHandler::new(ESC_KEY, &mut app, active_sonarr_block, None).handle(); EditSeriesHandler::new(ESC_KEY, &mut app, active_sonarr_block, None).handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app.get_current_route(), app.get_current_route(),
ActiveSonarrBlock::EditSeriesPrompt.into() ActiveSonarrBlock::EditSeriesPrompt.into()
@@ -1370,11 +1370,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_edit_series_handler_ignore_alt_navigation( fn test_edit_series_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = EditSeriesHandler::new( let handler = EditSeriesHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -1382,7 +1382,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -87,8 +87,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EpisodeDetailsHandle
EPISODE_DETAILS_BLOCKS.contains(&active_block) EPISODE_DETAILS_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -626,11 +626,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_episode_details_handler_ignore_alt_navigation( fn test_episode_details_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = EpisodeDetailsHandler::new( let handler = EpisodeDetailsHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -638,7 +638,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -316,7 +316,7 @@ mod tests {
app.get_current_route(), app.get_current_route(),
ActiveSonarrBlock::AddSeriesSearchInput.into() ActiveSonarrBlock::AddSeriesSearchInput.into()
); );
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
assert!(app.data.sonarr_data.add_series_search.is_some()); assert!(app.data.sonarr_data.add_series_search.is_some());
} }
@@ -340,7 +340,7 @@ mod tests {
.handle(); .handle();
assert_eq!(app.get_current_route(), ActiveSonarrBlock::Series.into()); assert_eq!(app.get_current_route(), ActiveSonarrBlock::Series.into());
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(app.data.sonarr_data.add_series_search.is_none()); assert!(app.data.sonarr_data.add_series_search.is_none());
} }
@@ -828,11 +828,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_library_handler_ignore_alt_navigation( fn test_library_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = LibraryHandler::new( let handler = LibraryHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -840,7 +840,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
+3 -3
View File
@@ -102,8 +102,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for LibraryHandler<'a, '
|| LIBRARY_BLOCKS.contains(&active_block) || LIBRARY_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -203,7 +203,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for LibraryHandler<'a, '
.app .app
.push_navigation_stack(ActiveSonarrBlock::AddSeriesSearchInput.into()); .push_navigation_stack(ActiveSonarrBlock::AddSeriesSearchInput.into());
self.app.data.sonarr_data.add_series_search = Some(HorizontallyScrollableText::default()); self.app.data.sonarr_data.add_series_search = Some(HorizontallyScrollableText::default());
self.app.should_ignore_quit_key = true; self.app.ignore_special_keys_for_textbox_input = true;
} }
_ if matches_key!(update, key) => { _ if matches_key!(update, key) => {
self self
@@ -139,8 +139,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeasonDetailsHandler
SEASON_DETAILS_BLOCKS.contains(&active_block) SEASON_DETAILS_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -790,11 +790,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_season_details_handler_ignore_alt_navigation( fn test_season_details_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = SeasonDetailsHandler::new( let handler = SeasonDetailsHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -802,7 +802,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -90,8 +90,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeriesDetailsHandler
SERIES_DETAILS_BLOCKS.contains(&active_block) SERIES_DETAILS_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -612,11 +612,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_series_details_handler_ignore_alt_navigation( fn test_series_details_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = SeriesDetailsHandler::new( let handler = SeriesDetailsHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -624,7 +624,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
+4 -4
View File
@@ -67,8 +67,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SonarrHandler<'a, 'b
true true
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -115,11 +115,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SonarrHandler<'a, 'b
pub fn handle_change_tab_left_right_keys(app: &mut App<'_>, key: Key) { pub fn handle_change_tab_left_right_keys(app: &mut App<'_>, key: Key) {
let key_ref = key; let key_ref = key;
match key_ref { match key_ref {
_ if matches_key!(left, key, app.should_ignore_quit_key) => { _ if matches_key!(left, key, app.ignore_special_keys_for_textbox_input) => {
app.data.sonarr_data.main_tabs.previous(); app.data.sonarr_data.main_tabs.previous();
app.pop_and_push_navigation_stack(app.data.sonarr_data.main_tabs.get_active_route()); app.pop_and_push_navigation_stack(app.data.sonarr_data.main_tabs.get_active_route());
} }
_ if matches_key!(right, key, app.should_ignore_quit_key) => { _ if matches_key!(right, key, app.ignore_special_keys_for_textbox_input) => {
app.data.sonarr_data.main_tabs.next(); app.data.sonarr_data.main_tabs.next();
app.pop_and_push_navigation_stack(app.data.sonarr_data.main_tabs.get_active_route()); app.pop_and_push_navigation_stack(app.data.sonarr_data.main_tabs.get_active_route());
} }
@@ -67,8 +67,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for RootFoldersHandler<'
ROOT_FOLDERS_BLOCKS.contains(&active_block) ROOT_FOLDERS_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -171,7 +171,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for RootFoldersHandler<'
self.build_add_root_folder_body(), self.build_add_root_folder_body(),
)); ));
self.app.data.sonarr_data.prompt_confirm = true; self.app.data.sonarr_data.prompt_confirm = true;
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
} }
_ => (), _ => (),
@@ -184,7 +184,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for RootFoldersHandler<'
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
self.app.data.sonarr_data.edit_root_folder = None; self.app.data.sonarr_data.edit_root_folder = None;
self.app.data.sonarr_data.prompt_confirm = false; self.app.data.sonarr_data.prompt_confirm = false;
self.app.should_ignore_quit_key = false; self.app.ignore_special_keys_for_textbox_input = false;
} }
ActiveSonarrBlock::DeleteRootFolderPrompt => { ActiveSonarrBlock::DeleteRootFolderPrompt => {
self.app.pop_navigation_stack(); self.app.pop_navigation_stack();
@@ -206,7 +206,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for RootFoldersHandler<'
.app .app
.push_navigation_stack(ActiveSonarrBlock::AddRootFolderPrompt.into()); .push_navigation_stack(ActiveSonarrBlock::AddRootFolderPrompt.into());
self.app.data.sonarr_data.edit_root_folder = Some(HorizontallyScrollableText::default()); self.app.data.sonarr_data.edit_root_folder = Some(HorizontallyScrollableText::default());
self.app.should_ignore_quit_key = true; self.app.ignore_special_keys_for_textbox_input = true;
} }
_ => (), _ => (),
}, },
@@ -270,7 +270,7 @@ mod tests {
.set_items(vec![RootFolder::default()]); .set_items(vec![RootFolder::default()]);
app.data.sonarr_data.edit_root_folder = Some("Test".into()); app.data.sonarr_data.edit_root_folder = Some("Test".into());
app.data.sonarr_data.prompt_confirm = true; app.data.sonarr_data.prompt_confirm = true;
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.push_navigation_stack(ActiveSonarrBlock::RootFolders.into()); app.push_navigation_stack(ActiveSonarrBlock::RootFolders.into());
app.push_navigation_stack(ActiveSonarrBlock::AddRootFolderPrompt.into()); app.push_navigation_stack(ActiveSonarrBlock::AddRootFolderPrompt.into());
@@ -283,7 +283,7 @@ mod tests {
.handle(); .handle();
assert!(app.data.sonarr_data.prompt_confirm); assert!(app.data.sonarr_data.prompt_confirm);
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app.data.sonarr_data.prompt_confirm_action, app.data.sonarr_data.prompt_confirm_action,
Some(SonarrEvent::AddRootFolder(expected_add_root_folder_body)) Some(SonarrEvent::AddRootFolder(expected_add_root_folder_body))
@@ -300,7 +300,7 @@ mod tests {
let mut app = App::test_default(); let mut app = App::test_default();
app.data.sonarr_data.edit_root_folder = Some(HorizontallyScrollableText::default()); app.data.sonarr_data.edit_root_folder = Some(HorizontallyScrollableText::default());
app.data.sonarr_data.prompt_confirm = false; app.data.sonarr_data.prompt_confirm = false;
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.push_navigation_stack(ActiveSonarrBlock::RootFolders.into()); app.push_navigation_stack(ActiveSonarrBlock::RootFolders.into());
app.push_navigation_stack(ActiveSonarrBlock::AddRootFolderPrompt.into()); app.push_navigation_stack(ActiveSonarrBlock::AddRootFolderPrompt.into());
@@ -313,7 +313,7 @@ mod tests {
.handle(); .handle();
assert!(!app.data.sonarr_data.prompt_confirm); assert!(!app.data.sonarr_data.prompt_confirm);
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
assert!(app.data.sonarr_data.prompt_confirm_action.is_none()); assert!(app.data.sonarr_data.prompt_confirm_action.is_none());
assert_eq!( assert_eq!(
app.get_current_route(), app.get_current_route(),
@@ -415,7 +415,7 @@ mod tests {
app.push_navigation_stack(ActiveSonarrBlock::RootFolders.into()); app.push_navigation_stack(ActiveSonarrBlock::RootFolders.into());
app.push_navigation_stack(ActiveSonarrBlock::AddRootFolderPrompt.into()); app.push_navigation_stack(ActiveSonarrBlock::AddRootFolderPrompt.into());
app.data.sonarr_data.edit_root_folder = Some("/nfs/test".into()); app.data.sonarr_data.edit_root_folder = Some("/nfs/test".into());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
RootFoldersHandler::new( RootFoldersHandler::new(
ESC_KEY, ESC_KEY,
@@ -432,7 +432,7 @@ mod tests {
assert!(app.data.sonarr_data.edit_root_folder.is_none()); assert!(app.data.sonarr_data.edit_root_folder.is_none());
assert!(!app.data.sonarr_data.prompt_confirm); assert!(!app.data.sonarr_data.prompt_confirm);
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
} }
#[rstest] #[rstest]
@@ -482,7 +482,7 @@ mod tests {
app.get_current_route(), app.get_current_route(),
ActiveSonarrBlock::AddRootFolderPrompt.into() ActiveSonarrBlock::AddRootFolderPrompt.into()
); );
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
assert!(app.data.sonarr_data.edit_root_folder.is_some()); assert!(app.data.sonarr_data.edit_root_folder.is_some());
} }
@@ -509,7 +509,7 @@ mod tests {
app.get_current_route(), app.get_current_route(),
ActiveSonarrBlock::RootFolders.into() ActiveSonarrBlock::RootFolders.into()
); );
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(app.data.sonarr_data.edit_root_folder.is_none()); assert!(app.data.sonarr_data.edit_root_folder.is_none());
} }
@@ -657,11 +657,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_root_folders_handler_ignore_alt_navigation( fn test_root_folders_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = RootFoldersHandler::new( let handler = RootFoldersHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -669,7 +669,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -95,7 +95,7 @@ mod tests {
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.push_navigation_stack(block.into()); app.push_navigation_stack(block.into());
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.data.sonarr_data.main_tabs.set_index(index); app.data.sonarr_data.main_tabs.set_index(index);
handle_change_tab_left_right_keys(&mut app, DEFAULT_KEYBINDINGS.left.alt.unwrap()); handle_change_tab_left_right_keys(&mut app, DEFAULT_KEYBINDINGS.left.alt.unwrap());
@@ -300,11 +300,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_sonarr_handler_ignore_alt_navigation( fn test_sonarr_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = SonarrHandler::new( let handler = SonarrHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -312,7 +312,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
+2 -2
View File
@@ -35,8 +35,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SystemHandler<'a, 'b
SystemDetailsHandler::accepts(active_block) || active_block == ActiveSonarrBlock::System SystemDetailsHandler::accepts(active_block) || active_block == ActiveSonarrBlock::System
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -36,8 +36,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SystemDetailsHandler
SYSTEM_DETAILS_BLOCKS.contains(&active_block) SYSTEM_DETAILS_BLOCKS.contains(&active_block)
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -962,11 +962,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_system_details_handler_ignore_alt_navigation( fn test_system_details_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = SystemDetailsHandler::new( let handler = SystemDetailsHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -974,7 +974,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
@@ -457,11 +457,11 @@ mod tests {
} }
#[rstest] #[rstest]
fn test_system_handler_ignore_alt_navigation( fn test_system_handler_ignore_special_keys(
#[values(true, false)] should_ignore_quit_key: bool, #[values(true, false)] ignore_special_keys_for_textbox_input: bool,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = should_ignore_quit_key; app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input;
let handler = SystemHandler::new( let handler = SystemHandler::new(
DEFAULT_KEYBINDINGS.esc.key, DEFAULT_KEYBINDINGS.esc.key,
&mut app, &mut app,
@@ -469,7 +469,10 @@ mod tests {
None, None,
); );
assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); assert_eq!(
handler.ignore_special_keys(),
ignore_special_keys_for_textbox_input
);
} }
#[test] #[test]
+10 -10
View File
@@ -42,12 +42,12 @@ macro_rules! handle_table_events {
fn [<handle_ $name _table_events>](&mut $self, config: $crate::handlers::table_handler::TableHandlingConfig<$row>) -> bool { fn [<handle_ $name _table_events>](&mut $self, config: $crate::handlers::table_handler::TableHandlingConfig<$row>) -> bool {
if $self.is_ready() { if $self.is_ready() {
match $self.key { match $self.key {
_ if $crate::matches_key!(up, $self.key, $self.ignore_alt_navigation()) => $self.[<handle_ $name _table_scroll_up>](config), _ if $crate::matches_key!(up, $self.key, $self.ignore_special_keys()) => $self.[<handle_ $name _table_scroll_up>](config),
_ if $crate::matches_key!(down, $self.key, $self.ignore_alt_navigation()) => $self.[<handle_ $name _table_scroll_down>](config), _ if $crate::matches_key!(down, $self.key, $self.ignore_special_keys()) => $self.[<handle_ $name _table_scroll_down>](config),
_ if $crate::matches_key!(home, $self.key) => $self.[<handle_ $name _table_home>](config), _ if $crate::matches_key!(home, $self.key) => $self.[<handle_ $name _table_home>](config),
_ if $crate::matches_key!(end, $self.key) => $self.[<handle_ $name _table_end>](config), _ if $crate::matches_key!(end, $self.key) => $self.[<handle_ $name _table_end>](config),
_ if $crate::matches_key!(left, $self.key, $self.ignore_alt_navigation()) _ if $crate::matches_key!(left, $self.key, $self.ignore_special_keys())
|| $crate::matches_key!(right, $self.key, $self.ignore_alt_navigation()) => || $crate::matches_key!(right, $self.key, $self.ignore_special_keys()) =>
{ {
$self.[<handle_ $name _table_left_right>](config) $self.[<handle_ $name _table_left_right>](config)
} }
@@ -244,7 +244,7 @@ macro_rules! handle_table_events {
&& $self.app.get_current_route() == *config.searching_block.as_ref().unwrap() => && $self.app.get_current_route() == *config.searching_block.as_ref().unwrap() =>
{ {
$self.app.pop_navigation_stack(); $self.app.pop_navigation_stack();
$self.app.should_ignore_quit_key = false; $self.app.ignore_special_keys_for_textbox_input = false;
if $table.search.is_some() { if $table.search.is_some() {
let search_field_fn = config let search_field_fn = config
@@ -267,7 +267,7 @@ macro_rules! handle_table_events {
&& $self.app.get_current_route() == *config.filtering_block.as_ref().unwrap() => && $self.app.get_current_route() == *config.filtering_block.as_ref().unwrap() =>
{ {
$self.app.pop_navigation_stack(); $self.app.pop_navigation_stack();
$self.app.should_ignore_quit_key = false; $self.app.ignore_special_keys_for_textbox_input = false;
if $table.filter.is_some() { if $table.filter.is_some() {
let filter_field_fn = config let filter_field_fn = config
@@ -305,7 +305,7 @@ macro_rules! handle_table_events {
{ {
$self.app.pop_navigation_stack(); $self.app.pop_navigation_stack();
$table.reset_search(); $table.reset_search();
$self.app.should_ignore_quit_key = false; $self.app.ignore_special_keys_for_textbox_input = false;
true true
} }
_ if (config.filtering_block.is_some() _ if (config.filtering_block.is_some()
@@ -315,7 +315,7 @@ macro_rules! handle_table_events {
{ {
$self.app.pop_navigation_stack(); $self.app.pop_navigation_stack();
$table.reset_filter(); $table.reset_filter();
$self.app.should_ignore_quit_key = false; $self.app.ignore_special_keys_for_textbox_input = false;
true true
} }
_ if config.table_block == $self.app.get_current_route() _ if config.table_block == $self.app.get_current_route()
@@ -335,7 +335,7 @@ macro_rules! handle_table_events {
.push_navigation_stack(config.filtering_block.expect("Filtering block is undefined").into()); .push_navigation_stack(config.filtering_block.expect("Filtering block is undefined").into());
$table.reset_filter(); $table.reset_filter();
$table.filter = Some($crate::models::HorizontallyScrollableText::default()); $table.filter = Some($crate::models::HorizontallyScrollableText::default());
$self.app.should_ignore_quit_key = true; $self.app.ignore_special_keys_for_textbox_input = true;
true true
} else { } else {
@@ -349,7 +349,7 @@ macro_rules! handle_table_events {
.app .app
.push_navigation_stack(config.searching_block.expect("Searching block is undefined")); .push_navigation_stack(config.searching_block.expect("Searching block is undefined"));
$table.search = Some($crate::models::HorizontallyScrollableText::default()); $table.search = Some($crate::models::HorizontallyScrollableText::default());
$self.app.should_ignore_quit_key = true; $self.app.ignore_special_keys_for_textbox_input = true;
true true
} else { } else {
+16 -16
View File
@@ -48,8 +48,8 @@ mod tests {
true true
} }
fn ignore_alt_navigation(&self) -> bool { fn ignore_special_keys(&self) -> bool {
self.app.should_ignore_quit_key self.app.ignore_special_keys_for_textbox_input
} }
fn new( fn new(
@@ -652,7 +652,7 @@ mod tests {
TableHandlerUnit::new(SUBMIT_KEY, &mut app, ActiveRadarrBlock::FilterMovies, None).handle(); TableHandlerUnit::new(SUBMIT_KEY, &mut app, ActiveRadarrBlock::FilterMovies, None).handle();
assert!(app.data.radarr_data.movies.filtered_items.is_some()); assert!(app.data.radarr_data.movies.filtered_items.is_some());
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app app
.data .data
@@ -688,7 +688,7 @@ mod tests {
TableHandlerUnit::new(SUBMIT_KEY, &mut app, ActiveRadarrBlock::FilterMovies, None).handle(); TableHandlerUnit::new(SUBMIT_KEY, &mut app, ActiveRadarrBlock::FilterMovies, None).handle();
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(app.data.radarr_data.movies.filtered_items.is_none()); assert!(app.data.radarr_data.movies.filtered_items.is_none());
assert_eq!( assert_eq!(
app.get_current_route(), app.get_current_route(),
@@ -739,7 +739,7 @@ mod tests {
active_radarr_block: ActiveRadarrBlock, active_radarr_block: ActiveRadarrBlock,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.push_navigation_stack(ActiveRadarrBlock::Movies.into()); app.push_navigation_stack(ActiveRadarrBlock::Movies.into());
app.push_navigation_stack(active_radarr_block.into()); app.push_navigation_stack(active_radarr_block.into());
app.data.radarr_data = create_test_radarr_data(); app.data.radarr_data = create_test_radarr_data();
@@ -748,7 +748,7 @@ mod tests {
TableHandlerUnit::new(ESC_KEY, &mut app, active_radarr_block, None).handle(); TableHandlerUnit::new(ESC_KEY, &mut app, active_radarr_block, None).handle();
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into()); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!(app.data.radarr_data.movies.search, None); assert_eq!(app.data.radarr_data.movies.search, None);
} }
@@ -758,7 +758,7 @@ mod tests {
active_radarr_block: ActiveRadarrBlock, active_radarr_block: ActiveRadarrBlock,
) { ) {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.push_navigation_stack(ActiveRadarrBlock::Movies.into()); app.push_navigation_stack(ActiveRadarrBlock::Movies.into());
app.push_navigation_stack(active_radarr_block.into()); app.push_navigation_stack(active_radarr_block.into());
app.data.radarr_data = create_test_radarr_data(); app.data.radarr_data = create_test_radarr_data();
@@ -777,7 +777,7 @@ mod tests {
TableHandlerUnit::new(ESC_KEY, &mut app, active_radarr_block, None).handle(); TableHandlerUnit::new(ESC_KEY, &mut app, active_radarr_block, None).handle();
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into()); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!(app.data.radarr_data.movies.filter, None); assert_eq!(app.data.radarr_data.movies.filter, None);
assert_eq!(app.data.radarr_data.movies.filtered_items, None); assert_eq!(app.data.radarr_data.movies.filtered_items, None);
assert_eq!(app.data.radarr_data.movies.filtered_state, None); assert_eq!(app.data.radarr_data.movies.filtered_state, None);
@@ -824,7 +824,7 @@ mod tests {
app.get_current_route(), app.get_current_route(),
ActiveRadarrBlock::SearchMovie.into() ActiveRadarrBlock::SearchMovie.into()
); );
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app.data.radarr_data.movies.search, app.data.radarr_data.movies.search,
Some(HorizontallyScrollableText::default()) Some(HorizontallyScrollableText::default())
@@ -851,7 +851,7 @@ mod tests {
.handle(); .handle();
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into()); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!(app.data.radarr_data.movies.search, None); assert_eq!(app.data.radarr_data.movies.search, None);
} }
@@ -873,7 +873,7 @@ mod tests {
.handle(); .handle();
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into()); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!(app.data.radarr_data.movies.search, None); assert_eq!(app.data.radarr_data.movies.search, None);
} }
@@ -898,7 +898,7 @@ mod tests {
app.get_current_route(), app.get_current_route(),
ActiveRadarrBlock::FilterMovies.into() ActiveRadarrBlock::FilterMovies.into()
); );
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
assert!(app.data.radarr_data.movies.filter.is_some()); assert!(app.data.radarr_data.movies.filter.is_some());
} }
@@ -922,14 +922,14 @@ mod tests {
.handle(); .handle();
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into()); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert!(app.data.radarr_data.movies.filter.is_none()); assert!(app.data.radarr_data.movies.filter.is_none());
} }
#[test] #[test]
fn test_filter_table_key_resets_previous_filter() { fn test_filter_table_key_resets_previous_filter() {
let mut app = App::test_default(); let mut app = App::test_default();
app.should_ignore_quit_key = true; app.ignore_special_keys_for_textbox_input = true;
app.push_navigation_stack(ActiveRadarrBlock::Movies.into()); app.push_navigation_stack(ActiveRadarrBlock::Movies.into());
app.data.radarr_data = create_test_radarr_data(); app.data.radarr_data = create_test_radarr_data();
app app
@@ -951,7 +951,7 @@ mod tests {
app.get_current_route(), app.get_current_route(),
ActiveRadarrBlock::FilterMovies.into() ActiveRadarrBlock::FilterMovies.into()
); );
assert!(app.should_ignore_quit_key); assert!(app.ignore_special_keys_for_textbox_input);
assert_eq!( assert_eq!(
app.data.radarr_data.movies.filter, app.data.radarr_data.movies.filter,
Some(HorizontallyScrollableText::default()) Some(HorizontallyScrollableText::default())
@@ -978,7 +978,7 @@ mod tests {
.handle(); .handle();
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into()); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
assert!(!app.should_ignore_quit_key); assert!(!app.ignore_special_keys_for_textbox_input);
assert_eq!(app.data.radarr_data.movies.filter, None); assert_eq!(app.data.radarr_data.movies.filter, None);
} }
+1 -1
View File
@@ -246,7 +246,7 @@ async fn start_ui(
match input_events.next()? { match input_events.next()? {
InputEvent::KeyEvent(key) => { InputEvent::KeyEvent(key) => {
if key == Key::Char('q') && !app.should_ignore_quit_key { if key == Key::Char('q') && !app.ignore_special_keys_for_textbox_input {
break; break;
} }