feat(app): Dispatch support for all relevant Sonarr blocks
This commit is contained in:
@@ -129,14 +129,14 @@ mod test_utils {
|
||||
.$data_ref
|
||||
.set_items(simple_stateful_iterable_vec!($items));
|
||||
|
||||
$handler::with(&key, &mut app, &$block, &$context).handle();
|
||||
$handler::with(key, &mut app, $block, $context).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.$data_ref.current_selection().$field,
|
||||
"Test 2"
|
||||
);
|
||||
|
||||
$handler::with(&key, &mut app, &$block, &$context).handle();
|
||||
$handler::with(key, &mut app, $block, $context).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.$data_ref.current_selection().$field,
|
||||
@@ -151,14 +151,14 @@ mod test_utils {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data.$data_ref.set_items($items);
|
||||
|
||||
$handler::with(&key, &mut app, &$block, &$context).handle();
|
||||
$handler::with(key, &mut app, $block, $context).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.$data_ref.current_selection().$field,
|
||||
"Test 2"
|
||||
);
|
||||
|
||||
$handler::with(&key, &mut app, &$block, &$context).handle();
|
||||
$handler::with(key, &mut app, $block, $context).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.$data_ref.current_selection().$field,
|
||||
@@ -173,7 +173,7 @@ mod test_utils {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data.$data_ref.set_items($items);
|
||||
|
||||
$handler::with(&key, &mut app, &$block, &$context).handle();
|
||||
$handler::with(key, &mut app, $block, $context).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -186,7 +186,7 @@ mod test_utils {
|
||||
"Test 2"
|
||||
);
|
||||
|
||||
$handler::with(&key, &mut app, &$block, &$context).handle();
|
||||
$handler::with(key, &mut app, $block, $context).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -214,11 +214,11 @@ mod test_utils {
|
||||
"Test 3".to_owned(),
|
||||
]);
|
||||
|
||||
$handler::with(&DEFAULT_KEYBINDINGS.end.key, &mut app, &$block, &$context).handle();
|
||||
$handler::with(DEFAULT_KEYBINDINGS.end.key, &mut app, $block, $context).handle();
|
||||
|
||||
assert_str_eq!(app.data.radarr_data.$data_ref.current_selection(), "Test 3");
|
||||
|
||||
$handler::with(&DEFAULT_KEYBINDINGS.home.key, &mut app, &$block, &$context).handle();
|
||||
$handler::with(DEFAULT_KEYBINDINGS.home.key, &mut app, $block, $context).handle();
|
||||
|
||||
assert_str_eq!(app.data.radarr_data.$data_ref.current_selection(), "Test 1");
|
||||
}
|
||||
@@ -234,14 +234,14 @@ mod test_utils {
|
||||
.$data_ref
|
||||
.set_items(extended_stateful_iterable_vec!($items));
|
||||
|
||||
$handler::with(&DEFAULT_KEYBINDINGS.end.key, &mut app, &$block, &$context).handle();
|
||||
$handler::with(DEFAULT_KEYBINDINGS.end.key, &mut app, $block, $context).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.$data_ref.current_selection().$field,
|
||||
"Test 3"
|
||||
);
|
||||
|
||||
$handler::with(&DEFAULT_KEYBINDINGS.home.key, &mut app, &$block, &$context).handle();
|
||||
$handler::with(DEFAULT_KEYBINDINGS.home.key, &mut app, $block, $context).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.$data_ref.current_selection().$field,
|
||||
@@ -256,14 +256,14 @@ mod test_utils {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data.$data_ref.set_items($items);
|
||||
|
||||
$handler::with(&DEFAULT_KEYBINDINGS.end.key, &mut app, &$block, &$context).handle();
|
||||
$handler::with(DEFAULT_KEYBINDINGS.end.key, &mut app, $block, $context).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.$data_ref.current_selection().$field,
|
||||
"Test 3"
|
||||
);
|
||||
|
||||
$handler::with(&DEFAULT_KEYBINDINGS.home.key, &mut app, &$block, &$context).handle();
|
||||
$handler::with(DEFAULT_KEYBINDINGS.home.key, &mut app, $block, $context).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.$data_ref.current_selection().$field,
|
||||
@@ -278,7 +278,7 @@ mod test_utils {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data.$data_ref.set_items($items);
|
||||
|
||||
$handler::with(&DEFAULT_KEYBINDINGS.end.key, &mut app, &$block, &$context).handle();
|
||||
$handler::with(DEFAULT_KEYBINDINGS.end.key, &mut app, $block, $context).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -291,7 +291,7 @@ mod test_utils {
|
||||
"Test 3"
|
||||
);
|
||||
|
||||
$handler::with(&DEFAULT_KEYBINDINGS.home.key, &mut app, &$block, &$context).handle();
|
||||
$handler::with(DEFAULT_KEYBINDINGS.home.key, &mut app, $block, $context).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -311,18 +311,12 @@ mod test_utils {
|
||||
macro_rules! test_handler_delegation {
|
||||
($handler:ident, $base:expr, $active_block:expr) => {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack($base.clone().into());
|
||||
app.push_navigation_stack($active_block.clone().into());
|
||||
app.push_navigation_stack($base.into());
|
||||
app.push_navigation_stack($active_block.into());
|
||||
|
||||
$handler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&$active_block,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
$handler::with(DEFAULT_KEYBINDINGS.esc.key, &mut app, $active_block, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &$base.into());
|
||||
assert_eq!(app.get_current_route(), $base.into());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use pretty_assertions::assert_eq;
|
||||
use rstest::rstest;
|
||||
|
||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||
use crate::app::App;
|
||||
use crate::event::Key;
|
||||
use crate::handlers::handle_events;
|
||||
use crate::handlers::{handle_clear_errors, handle_prompt_toggle};
|
||||
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::ActiveSonarrBlock;
|
||||
use crate::models::Route;
|
||||
|
||||
#[test]
|
||||
fn test_handle_clear_errors() {
|
||||
@@ -16,17 +22,40 @@ mod tests {
|
||||
assert!(app.error.text.is_empty());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[case(0, ActiveSonarrBlock::Series, ActiveSonarrBlock::Series)]
|
||||
#[case(1, ActiveRadarrBlock::Movies, ActiveRadarrBlock::Movies)]
|
||||
fn test_handle_change_tabs<T>(#[case] index: usize, #[case] left_block: T, #[case] right_block: T)
|
||||
where
|
||||
T: Into<Route> + Copy,
|
||||
{
|
||||
let mut app = App::default();
|
||||
app.server_tabs.set_index(index);
|
||||
|
||||
handle_events(DEFAULT_KEYBINDINGS.previous_servarr.key, &mut app);
|
||||
|
||||
assert_eq!(app.server_tabs.get_active_route(), left_block.into());
|
||||
assert_eq!(app.get_current_route(), left_block.into());
|
||||
|
||||
app.server_tabs.set_index(index);
|
||||
|
||||
handle_events(DEFAULT_KEYBINDINGS.next_servarr.key, &mut app);
|
||||
|
||||
assert_eq!(app.server_tabs.get_active_route(), right_block.into());
|
||||
assert_eq!(app.get_current_route(), right_block.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
fn test_handle_prompt_toggle_left_right(#[values(Key::Left, Key::Right)] key: Key) {
|
||||
let mut app = App::default();
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
|
||||
handle_prompt_toggle(&mut app, &key);
|
||||
handle_prompt_toggle(&mut app, key);
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
handle_prompt_toggle(&mut app, &key);
|
||||
handle_prompt_toggle(&mut app, key);
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
|
||||
+27
-21
@@ -15,44 +15,44 @@ mod handlers_tests;
|
||||
#[path = "handler_test_utils.rs"]
|
||||
pub mod handler_test_utils;
|
||||
|
||||
pub trait KeyEventHandler<'a, 'b, T: Into<Route>> {
|
||||
pub trait KeyEventHandler<'a, 'b, T: Into<Route> + Copy> {
|
||||
fn handle_key_event(&mut self) {
|
||||
let key = self.get_key();
|
||||
match key {
|
||||
_ if *key == DEFAULT_KEYBINDINGS.up.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.up.key => {
|
||||
if self.is_ready() {
|
||||
self.handle_scroll_up();
|
||||
}
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.down.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.down.key => {
|
||||
if self.is_ready() {
|
||||
self.handle_scroll_down();
|
||||
}
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.home.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.home.key => {
|
||||
if self.is_ready() {
|
||||
self.handle_home();
|
||||
}
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.end.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.end.key => {
|
||||
if self.is_ready() {
|
||||
self.handle_end();
|
||||
}
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.delete.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.delete.key => {
|
||||
if self.is_ready() {
|
||||
self.handle_delete();
|
||||
}
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.left.key || *key == DEFAULT_KEYBINDINGS.right.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.left.key || key == DEFAULT_KEYBINDINGS.right.key => {
|
||||
self.handle_left_right_action()
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.submit.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.submit.key => {
|
||||
if self.is_ready() {
|
||||
self.handle_submit();
|
||||
}
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.esc.key => self.handle_esc(),
|
||||
_ if key == DEFAULT_KEYBINDINGS.esc.key => self.handle_esc(),
|
||||
_ => {
|
||||
if self.is_ready() {
|
||||
self.handle_char_key_event();
|
||||
@@ -65,9 +65,9 @@ pub trait KeyEventHandler<'a, 'b, T: Into<Route>> {
|
||||
self.handle_key_event();
|
||||
}
|
||||
|
||||
fn accepts(active_block: &'a T) -> bool;
|
||||
fn with(key: &'a Key, app: &'a mut App<'b>, active_block: &'a T, context: &'a Option<T>) -> Self;
|
||||
fn get_key(&self) -> &Key;
|
||||
fn accepts(active_block: T) -> bool;
|
||||
fn with(key: Key, app: &'a mut App<'b>, active_block: T, context: Option<T>) -> Self;
|
||||
fn get_key(&self) -> Key;
|
||||
fn is_ready(&self) -> bool;
|
||||
fn handle_scroll_up(&mut self);
|
||||
fn handle_scroll_down(&mut self);
|
||||
@@ -81,8 +81,14 @@ pub trait KeyEventHandler<'a, 'b, T: Into<Route>> {
|
||||
}
|
||||
|
||||
pub fn handle_events(key: Key, app: &mut App<'_>) {
|
||||
if let Route::Radarr(active_radarr_block, context) = *app.get_current_route() {
|
||||
RadarrHandler::with(&key, app, &active_radarr_block, &context).handle()
|
||||
if key == DEFAULT_KEYBINDINGS.next_servarr.key {
|
||||
app.server_tabs.next();
|
||||
app.pop_and_push_navigation_stack(app.server_tabs.get_active_route());
|
||||
} else if key == DEFAULT_KEYBINDINGS.previous_servarr.key {
|
||||
app.server_tabs.previous();
|
||||
app.pop_and_push_navigation_stack(app.server_tabs.get_active_route());
|
||||
} else if let Route::Radarr(active_radarr_block, context) = app.get_current_route() {
|
||||
RadarrHandler::with(key, app, active_radarr_block, context).handle()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,10 +98,10 @@ fn handle_clear_errors(app: &mut App<'_>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_prompt_toggle(app: &mut App<'_>, key: &Key) {
|
||||
fn handle_prompt_toggle(app: &mut App<'_>, key: Key) {
|
||||
match key {
|
||||
_ if *key == DEFAULT_KEYBINDINGS.left.key || *key == DEFAULT_KEYBINDINGS.right.key => {
|
||||
if let Route::Radarr(_, _) = *app.get_current_route() {
|
||||
_ if key == DEFAULT_KEYBINDINGS.left.key || key == DEFAULT_KEYBINDINGS.right.key => {
|
||||
if let Route::Radarr(_, _) = app.get_current_route() {
|
||||
app.data.radarr_data.prompt_confirm = !app.data.radarr_data.prompt_confirm;
|
||||
}
|
||||
}
|
||||
@@ -107,10 +113,10 @@ fn handle_prompt_toggle(app: &mut App<'_>, key: &Key) {
|
||||
macro_rules! handle_text_box_left_right_keys {
|
||||
($self:expr, $key:expr, $input:expr) => {
|
||||
match $self.key {
|
||||
_ if *$key == DEFAULT_KEYBINDINGS.left.key => {
|
||||
_ if $key == DEFAULT_KEYBINDINGS.left.key => {
|
||||
$input.scroll_left();
|
||||
}
|
||||
_ if *$key == DEFAULT_KEYBINDINGS.right.key => {
|
||||
_ if $key == DEFAULT_KEYBINDINGS.right.key => {
|
||||
$input.scroll_right();
|
||||
}
|
||||
_ => (),
|
||||
@@ -122,11 +128,11 @@ macro_rules! handle_text_box_left_right_keys {
|
||||
macro_rules! handle_text_box_keys {
|
||||
($self:expr, $key:expr, $input:expr) => {
|
||||
match $self.key {
|
||||
_ if *$key == DEFAULT_KEYBINDINGS.backspace.key => {
|
||||
_ if $key == DEFAULT_KEYBINDINGS.backspace.key => {
|
||||
$input.pop();
|
||||
}
|
||||
Key::Char(character) => {
|
||||
$input.push(*character);
|
||||
$input.push(character);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ mod tests {
|
||||
source_title
|
||||
));
|
||||
|
||||
BlocklistHandler::with(&key, &mut app, &ActiveRadarrBlock::Blocklist, &None).handle();
|
||||
BlocklistHandler::with(key, &mut app, ActiveRadarrBlock::Blocklist, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -65,7 +65,7 @@ mod tests {
|
||||
"Test 1"
|
||||
);
|
||||
|
||||
BlocklistHandler::with(&key, &mut app, &ActiveRadarrBlock::Blocklist, &None).handle();
|
||||
BlocklistHandler::with(key, &mut app, ActiveRadarrBlock::Blocklist, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -89,13 +89,8 @@ mod tests {
|
||||
|
||||
if key == Key::Up {
|
||||
for i in (0..blocklist_field_vec.len()).rev() {
|
||||
BlocklistHandler::with(
|
||||
&key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::BlocklistSortPrompt,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
BlocklistHandler::with(key, &mut app, ActiveRadarrBlock::BlocklistSortPrompt, None)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app
|
||||
@@ -111,13 +106,8 @@ mod tests {
|
||||
}
|
||||
} else {
|
||||
for i in 0..blocklist_field_vec.len() {
|
||||
BlocklistHandler::with(
|
||||
&key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::BlocklistSortPrompt,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
BlocklistHandler::with(key, &mut app, ActiveRadarrBlock::BlocklistSortPrompt, None)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app
|
||||
@@ -169,10 +159,10 @@ mod tests {
|
||||
));
|
||||
|
||||
BlocklistHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Blocklist,
|
||||
&None,
|
||||
ActiveRadarrBlock::Blocklist,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -188,10 +178,10 @@ mod tests {
|
||||
);
|
||||
|
||||
BlocklistHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Blocklist,
|
||||
&None,
|
||||
ActiveRadarrBlock::Blocklist,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -214,10 +204,10 @@ mod tests {
|
||||
app.data.radarr_data.blocklist.sorting(sort_options());
|
||||
|
||||
BlocklistHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::BlocklistSortPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::BlocklistSortPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -234,10 +224,10 @@ mod tests {
|
||||
);
|
||||
|
||||
BlocklistHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::BlocklistSortPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::BlocklistSortPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -267,11 +257,11 @@ mod tests {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data.blocklist.set_items(blocklist_vec());
|
||||
|
||||
BlocklistHandler::with(&DELETE_KEY, &mut app, &ActiveRadarrBlock::Blocklist, &None).handle();
|
||||
BlocklistHandler::with(DELETE_KEY, &mut app, ActiveRadarrBlock::Blocklist, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::DeleteBlocklistItemPrompt.into()
|
||||
ActiveRadarrBlock::DeleteBlocklistItemPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -282,12 +272,9 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Blocklist.into());
|
||||
app.data.radarr_data.blocklist.set_items(blocklist_vec());
|
||||
|
||||
BlocklistHandler::with(&DELETE_KEY, &mut app, &ActiveRadarrBlock::Blocklist, &None).handle();
|
||||
BlocklistHandler::with(DELETE_KEY, &mut app, ActiveRadarrBlock::Blocklist, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Blocklist.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Blocklist.into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,21 +291,18 @@ mod tests {
|
||||
app.data.radarr_data.main_tabs.set_index(3);
|
||||
|
||||
BlocklistHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Blocklist,
|
||||
&None,
|
||||
ActiveRadarrBlock::Blocklist,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.main_tabs.get_active_route(),
|
||||
&ActiveRadarrBlock::Downloads.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Downloads.into()
|
||||
ActiveRadarrBlock::Downloads.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Downloads.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -328,20 +312,20 @@ mod tests {
|
||||
app.data.radarr_data.main_tabs.set_index(3);
|
||||
|
||||
BlocklistHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Blocklist,
|
||||
&None,
|
||||
ActiveRadarrBlock::Blocklist,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.main_tabs.get_active_route(),
|
||||
&ActiveRadarrBlock::RootFolders.into()
|
||||
ActiveRadarrBlock::RootFolders.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::RootFolders.into()
|
||||
ActiveRadarrBlock::RootFolders.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -356,11 +340,11 @@ mod tests {
|
||||
) {
|
||||
let mut app = App::default();
|
||||
|
||||
BlocklistHandler::with(&key, &mut app, &active_radarr_block, &None).handle();
|
||||
BlocklistHandler::with(key, &mut app, active_radarr_block, None).handle();
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
BlocklistHandler::with(&key, &mut app, &active_radarr_block, &None).handle();
|
||||
BlocklistHandler::with(key, &mut app, active_radarr_block, None).handle();
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
@@ -382,11 +366,11 @@ mod tests {
|
||||
app.data.radarr_data.blocklist.set_items(blocklist_vec());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Blocklist.into());
|
||||
|
||||
BlocklistHandler::with(&SUBMIT_KEY, &mut app, &ActiveRadarrBlock::Blocklist, &None).handle();
|
||||
BlocklistHandler::with(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Blocklist, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::BlocklistItemDetails.into()
|
||||
ActiveRadarrBlock::BlocklistItemDetails.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -397,12 +381,9 @@ mod tests {
|
||||
app.data.radarr_data.blocklist.set_items(blocklist_vec());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Blocklist.into());
|
||||
|
||||
BlocklistHandler::with(&SUBMIT_KEY, &mut app, &ActiveRadarrBlock::Blocklist, &None).handle();
|
||||
BlocklistHandler::with(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Blocklist, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Blocklist.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Blocklist.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -427,14 +408,14 @@ mod tests {
|
||||
app.push_navigation_stack(base_route.into());
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
|
||||
BlocklistHandler::with(&SUBMIT_KEY, &mut app, &prompt_block, &None).handle();
|
||||
BlocklistHandler::with(SUBMIT_KEY, &mut app, prompt_block, None).handle();
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
assert_eq!(
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
Some(expected_action)
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &base_route.into());
|
||||
assert_eq!(app.get_current_route(), base_route.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -450,14 +431,11 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Blocklist.into());
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
|
||||
BlocklistHandler::with(&SUBMIT_KEY, &mut app, &prompt_block, &None).handle();
|
||||
BlocklistHandler::with(SUBMIT_KEY, &mut app, prompt_block, None).handle();
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Blocklist.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Blocklist.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -474,17 +452,14 @@ mod tests {
|
||||
expected_vec.reverse();
|
||||
|
||||
BlocklistHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::BlocklistSortPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::BlocklistSortPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Blocklist.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Blocklist.into());
|
||||
assert_eq!(app.data.radarr_data.blocklist.items, expected_vec);
|
||||
}
|
||||
}
|
||||
@@ -517,9 +492,9 @@ mod tests {
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
app.data.radarr_data.prompt_confirm = true;
|
||||
|
||||
BlocklistHandler::with(&ESC_KEY, &mut app, &prompt_block, &None).handle();
|
||||
BlocklistHandler::with(ESC_KEY, &mut app, prompt_block, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &base_block.into());
|
||||
assert_eq!(app.get_current_route(), base_block.into());
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
|
||||
@@ -530,17 +505,14 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::BlocklistItemDetails.into());
|
||||
|
||||
BlocklistHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::BlocklistItemDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::BlocklistItemDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Blocklist.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Blocklist.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -550,17 +522,14 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::BlocklistSortPrompt.into());
|
||||
|
||||
BlocklistHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::BlocklistSortPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::BlocklistSortPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Blocklist.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Blocklist.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -571,12 +540,9 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Blocklist.into());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Blocklist.into());
|
||||
|
||||
DownloadsHandler::with(&ESC_KEY, &mut app, &ActiveRadarrBlock::Blocklist, &None).handle();
|
||||
DownloadsHandler::with(ESC_KEY, &mut app, ActiveRadarrBlock::Blocklist, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Blocklist.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Blocklist.into());
|
||||
assert!(app.error.text.is_empty());
|
||||
}
|
||||
}
|
||||
@@ -596,17 +562,14 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Blocklist.into());
|
||||
|
||||
BlocklistHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.refresh.key,
|
||||
DEFAULT_KEYBINDINGS.refresh.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Blocklist,
|
||||
&None,
|
||||
ActiveRadarrBlock::Blocklist,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Blocklist.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Blocklist.into());
|
||||
assert!(app.should_refresh);
|
||||
}
|
||||
|
||||
@@ -618,17 +581,14 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Blocklist.into());
|
||||
|
||||
BlocklistHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.refresh.key,
|
||||
DEFAULT_KEYBINDINGS.refresh.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Blocklist,
|
||||
&None,
|
||||
ActiveRadarrBlock::Blocklist,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Blocklist.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Blocklist.into());
|
||||
assert!(!app.should_refresh);
|
||||
}
|
||||
|
||||
@@ -638,16 +598,16 @@ mod tests {
|
||||
app.data.radarr_data.blocklist.set_items(blocklist_vec());
|
||||
|
||||
BlocklistHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.clear.key,
|
||||
DEFAULT_KEYBINDINGS.clear.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Blocklist,
|
||||
&None,
|
||||
ActiveRadarrBlock::Blocklist,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::BlocklistClearAllItemsPrompt.into()
|
||||
ActiveRadarrBlock::BlocklistClearAllItemsPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -659,17 +619,14 @@ mod tests {
|
||||
app.data.radarr_data.blocklist.set_items(blocklist_vec());
|
||||
|
||||
BlocklistHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.clear.key,
|
||||
DEFAULT_KEYBINDINGS.clear.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Blocklist,
|
||||
&None,
|
||||
ActiveRadarrBlock::Blocklist,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Blocklist.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Blocklist.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -678,16 +635,16 @@ mod tests {
|
||||
app.data.radarr_data.blocklist.set_items(blocklist_vec());
|
||||
|
||||
BlocklistHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.sort.key,
|
||||
DEFAULT_KEYBINDINGS.sort.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Blocklist,
|
||||
&None,
|
||||
ActiveRadarrBlock::Blocklist,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::BlocklistSortPrompt.into()
|
||||
ActiveRadarrBlock::BlocklistSortPrompt.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.data.radarr_data.blocklist.sort.as_ref().unwrap().items,
|
||||
@@ -704,17 +661,14 @@ mod tests {
|
||||
app.data.radarr_data.blocklist.set_items(blocklist_vec());
|
||||
|
||||
BlocklistHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.sort.key,
|
||||
DEFAULT_KEYBINDINGS.sort.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Blocklist,
|
||||
&None,
|
||||
ActiveRadarrBlock::Blocklist,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Blocklist.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Blocklist.into());
|
||||
assert!(app.data.radarr_data.blocklist.sort.is_none());
|
||||
assert!(!app.data.radarr_data.blocklist.sort_asc);
|
||||
}
|
||||
@@ -741,10 +695,10 @@ mod tests {
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
|
||||
BlocklistHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.confirm.key,
|
||||
DEFAULT_KEYBINDINGS.confirm.key,
|
||||
&mut app,
|
||||
&prompt_block,
|
||||
&None,
|
||||
prompt_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -753,7 +707,7 @@ mod tests {
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
Some(expected_action)
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &base_route.into());
|
||||
assert_eq!(app.get_current_route(), base_route.into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -896,9 +850,9 @@ mod tests {
|
||||
fn test_blocklist_handler_accepts() {
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if BLOCKLIST_BLOCKS.contains(&active_radarr_block) {
|
||||
assert!(BlocklistHandler::accepts(&active_radarr_block));
|
||||
assert!(BlocklistHandler::accepts(active_radarr_block));
|
||||
} else {
|
||||
assert!(!BlocklistHandler::accepts(&active_radarr_block));
|
||||
assert!(!BlocklistHandler::accepts(active_radarr_block));
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -909,10 +863,10 @@ mod tests {
|
||||
app.is_loading = true;
|
||||
|
||||
let handler = BlocklistHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Blocklist,
|
||||
&None,
|
||||
ActiveRadarrBlock::Blocklist,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -924,10 +878,10 @@ mod tests {
|
||||
app.is_loading = false;
|
||||
|
||||
let handler = BlocklistHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Blocklist,
|
||||
&None,
|
||||
ActiveRadarrBlock::Blocklist,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -944,10 +898,10 @@ mod tests {
|
||||
.set_items(vec![BlocklistItem::default()]);
|
||||
|
||||
let handler = BlocklistHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Blocklist,
|
||||
&None,
|
||||
ActiveRadarrBlock::Blocklist,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
|
||||
@@ -14,22 +14,22 @@ use crate::network::radarr_network::RadarrEvent;
|
||||
mod blocklist_handler_tests;
|
||||
|
||||
pub(super) struct BlocklistHandler<'a, 'b> {
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_radarr_block: &'a ActiveRadarrBlock,
|
||||
_context: &'a Option<ActiveRadarrBlock>,
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for BlocklistHandler<'a, 'b> {
|
||||
fn accepts(active_block: &'a ActiveRadarrBlock) -> bool {
|
||||
BLOCKLIST_BLOCKS.contains(active_block)
|
||||
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
||||
BLOCKLIST_BLOCKS.contains(&active_block)
|
||||
}
|
||||
|
||||
fn with(
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_block: &'a ActiveRadarrBlock,
|
||||
context: &'a Option<ActiveRadarrBlock>,
|
||||
active_block: ActiveRadarrBlock,
|
||||
context: Option<ActiveRadarrBlock>,
|
||||
) -> Self {
|
||||
BlocklistHandler {
|
||||
key,
|
||||
@@ -39,7 +39,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for BlocklistHandler<'a,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_key(&self) -> &Key {
|
||||
fn get_key(&self) -> Key {
|
||||
self.key
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for BlocklistHandler<'a,
|
||||
}
|
||||
|
||||
fn handle_delete(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::Blocklist {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::Blocklist {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::DeleteBlocklistItemPrompt.into());
|
||||
@@ -184,15 +184,15 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for BlocklistHandler<'a,
|
||||
let key = self.key;
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::Blocklist => match self.key {
|
||||
_ if *key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||
self.app.should_refresh = true;
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.clear.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.clear.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::BlocklistClearAllItemsPrompt.into());
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.sort.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.sort.key => {
|
||||
self
|
||||
.app
|
||||
.data
|
||||
@@ -206,7 +206,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for BlocklistHandler<'a,
|
||||
_ => (),
|
||||
},
|
||||
ActiveRadarrBlock::DeleteBlocklistItemPrompt => {
|
||||
if *key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
if key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action =
|
||||
Some(RadarrEvent::DeleteBlocklistItem(None));
|
||||
@@ -215,7 +215,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for BlocklistHandler<'a,
|
||||
}
|
||||
}
|
||||
ActiveRadarrBlock::BlocklistClearAllItemsPrompt => {
|
||||
if *key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
if key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action = Some(RadarrEvent::ClearBlocklist);
|
||||
|
||||
|
||||
@@ -14,22 +14,22 @@ use crate::models::{BlockSelectionState, Scrollable};
|
||||
mod collection_details_handler_tests;
|
||||
|
||||
pub(super) struct CollectionDetailsHandler<'a, 'b> {
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_radarr_block: &'a ActiveRadarrBlock,
|
||||
_context: &'a Option<ActiveRadarrBlock>,
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionDetailsHandler<'a, 'b> {
|
||||
fn accepts(active_block: &'a ActiveRadarrBlock) -> bool {
|
||||
COLLECTION_DETAILS_BLOCKS.contains(active_block)
|
||||
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
||||
COLLECTION_DETAILS_BLOCKS.contains(&active_block)
|
||||
}
|
||||
|
||||
fn with(
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_block: &'a ActiveRadarrBlock,
|
||||
_context: &'a Option<ActiveRadarrBlock>,
|
||||
active_block: ActiveRadarrBlock,
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
) -> CollectionDetailsHandler<'a, 'b> {
|
||||
CollectionDetailsHandler {
|
||||
key,
|
||||
@@ -39,7 +39,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionDetailsHan
|
||||
}
|
||||
}
|
||||
|
||||
fn get_key(&self) -> &Key {
|
||||
fn get_key(&self) -> Key {
|
||||
self.key
|
||||
}
|
||||
|
||||
@@ -48,25 +48,25 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionDetailsHan
|
||||
}
|
||||
|
||||
fn handle_scroll_up(&mut self) {
|
||||
if ActiveRadarrBlock::CollectionDetails == *self.active_radarr_block {
|
||||
if ActiveRadarrBlock::CollectionDetails == self.active_radarr_block {
|
||||
self.app.data.radarr_data.collection_movies.scroll_up()
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_scroll_down(&mut self) {
|
||||
if ActiveRadarrBlock::CollectionDetails == *self.active_radarr_block {
|
||||
if ActiveRadarrBlock::CollectionDetails == self.active_radarr_block {
|
||||
self.app.data.radarr_data.collection_movies.scroll_down()
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_home(&mut self) {
|
||||
if ActiveRadarrBlock::CollectionDetails == *self.active_radarr_block {
|
||||
if ActiveRadarrBlock::CollectionDetails == self.active_radarr_block {
|
||||
self.app.data.radarr_data.collection_movies.scroll_to_top();
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_end(&mut self) {
|
||||
if ActiveRadarrBlock::CollectionDetails == *self.active_radarr_block {
|
||||
if ActiveRadarrBlock::CollectionDetails == self.active_radarr_block {
|
||||
self
|
||||
.app
|
||||
.data
|
||||
@@ -81,7 +81,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionDetailsHan
|
||||
fn handle_left_right_action(&mut self) {}
|
||||
|
||||
fn handle_submit(&mut self) {
|
||||
if ActiveRadarrBlock::CollectionDetails == *self.active_radarr_block {
|
||||
if ActiveRadarrBlock::CollectionDetails == self.active_radarr_block {
|
||||
let tmdb_id = self
|
||||
.app
|
||||
.data
|
||||
@@ -129,13 +129,13 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionDetailsHan
|
||||
}
|
||||
|
||||
fn handle_char_key_event(&mut self) {
|
||||
if *self.active_radarr_block == ActiveRadarrBlock::CollectionDetails
|
||||
&& *self.key == DEFAULT_KEYBINDINGS.edit.key
|
||||
if self.active_radarr_block == ActiveRadarrBlock::CollectionDetails
|
||||
&& self.key == DEFAULT_KEYBINDINGS.edit.key
|
||||
{
|
||||
self.app.push_navigation_stack(
|
||||
(
|
||||
ActiveRadarrBlock::EditCollectionPrompt,
|
||||
Some(*self.active_radarr_block),
|
||||
Some(self.active_radarr_block),
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
|
||||
@@ -50,7 +50,7 @@ mod tests {
|
||||
HorizontallyScrollableText
|
||||
));
|
||||
|
||||
CollectionDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::CollectionDetails, &None)
|
||||
CollectionDetailsHandler::with(key, &mut app, ActiveRadarrBlock::CollectionDetails, None)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(
|
||||
@@ -64,7 +64,7 @@ mod tests {
|
||||
"Test 1"
|
||||
);
|
||||
|
||||
CollectionDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::CollectionDetails, &None)
|
||||
CollectionDetailsHandler::with(key, &mut app, ActiveRadarrBlock::CollectionDetails, None)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(
|
||||
@@ -110,10 +110,10 @@ mod tests {
|
||||
));
|
||||
|
||||
CollectionDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::CollectionDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::CollectionDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -129,10 +129,10 @@ mod tests {
|
||||
);
|
||||
|
||||
CollectionDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::CollectionDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::CollectionDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -179,16 +179,16 @@ mod tests {
|
||||
.set_index(ADD_MOVIE_SELECTION_BLOCKS.len() - 1);
|
||||
|
||||
CollectionDetailsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::CollectionDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::CollectionDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&(
|
||||
(
|
||||
ActiveRadarrBlock::AddMoviePrompt,
|
||||
Some(ActiveRadarrBlock::CollectionDetails)
|
||||
)
|
||||
@@ -205,7 +205,7 @@ mod tests {
|
||||
.is_empty());
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::AddMovieSelectRootFolder
|
||||
ActiveRadarrBlock::AddMovieSelectRootFolder
|
||||
);
|
||||
assert!(!app
|
||||
.data
|
||||
@@ -250,16 +250,16 @@ mod tests {
|
||||
.set_items(vec![CollectionMovie::default()]);
|
||||
|
||||
CollectionDetailsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::CollectionDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::CollectionDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::CollectionDetails.into()
|
||||
ActiveRadarrBlock::CollectionDetails.into()
|
||||
);
|
||||
assert!(app.data.radarr_data.add_movie_modal.is_none());
|
||||
}
|
||||
@@ -279,16 +279,16 @@ mod tests {
|
||||
.set_items(vec![Movie::default()]);
|
||||
|
||||
CollectionDetailsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::CollectionDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::CollectionDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::ViewMovieOverview.into()
|
||||
ActiveRadarrBlock::ViewMovieOverview.into()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -313,16 +313,16 @@ mod tests {
|
||||
.set_items(vec![CollectionMovie::default()]);
|
||||
|
||||
CollectionDetailsHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::CollectionDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::CollectionDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
assert!(app.data.radarr_data.collection_movies.items.is_empty());
|
||||
}
|
||||
@@ -334,16 +334,16 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::ViewMovieOverview.into());
|
||||
|
||||
CollectionDetailsHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::ViewMovieOverview,
|
||||
&None,
|
||||
ActiveRadarrBlock::ViewMovieOverview,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::CollectionDetails.into()
|
||||
ActiveRadarrBlock::CollectionDetails.into()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -388,16 +388,16 @@ mod tests {
|
||||
app.data.radarr_data = radarr_data;
|
||||
|
||||
CollectionDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.edit.key,
|
||||
DEFAULT_KEYBINDINGS.edit.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::CollectionDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::CollectionDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::CollectionDetails.into()
|
||||
ActiveRadarrBlock::CollectionDetails.into()
|
||||
);
|
||||
assert!(app.data.radarr_data.edit_collection_modal.is_none());
|
||||
}
|
||||
@@ -407,9 +407,9 @@ mod tests {
|
||||
fn test_collection_details_handler_accepts() {
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if COLLECTION_DETAILS_BLOCKS.contains(&active_radarr_block) {
|
||||
assert!(CollectionDetailsHandler::accepts(&active_radarr_block));
|
||||
assert!(CollectionDetailsHandler::accepts(active_radarr_block));
|
||||
} else {
|
||||
assert!(!CollectionDetailsHandler::accepts(&active_radarr_block));
|
||||
assert!(!CollectionDetailsHandler::accepts(active_radarr_block));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -420,10 +420,10 @@ mod tests {
|
||||
app.is_loading = true;
|
||||
|
||||
let handler = CollectionDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::CollectionDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::CollectionDetails,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -435,10 +435,10 @@ mod tests {
|
||||
app.is_loading = false;
|
||||
|
||||
let handler = CollectionDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::CollectionDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::CollectionDetails,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -455,10 +455,10 @@ mod tests {
|
||||
.set_items(vec![CollectionMovie::default()]);
|
||||
|
||||
let handler = CollectionDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::CollectionDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::CollectionDetails,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
|
||||
@@ -60,7 +60,7 @@ mod tests {
|
||||
HorizontallyScrollableText
|
||||
));
|
||||
|
||||
CollectionsHandler::with(&key, &mut app, &ActiveRadarrBlock::Collections, &None).handle();
|
||||
CollectionsHandler::with(key, &mut app, ActiveRadarrBlock::Collections, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -73,7 +73,7 @@ mod tests {
|
||||
"Test 1"
|
||||
);
|
||||
|
||||
CollectionsHandler::with(&key, &mut app, &ActiveRadarrBlock::Collections, &None).handle();
|
||||
CollectionsHandler::with(key, &mut app, ActiveRadarrBlock::Collections, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -98,10 +98,10 @@ mod tests {
|
||||
if key == Key::Up {
|
||||
for i in (0..collection_field_vec.len()).rev() {
|
||||
CollectionsHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::CollectionsSortPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::CollectionsSortPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -120,10 +120,10 @@ mod tests {
|
||||
} else {
|
||||
for i in 0..collection_field_vec.len() {
|
||||
CollectionsHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::CollectionsSortPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::CollectionsSortPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -175,10 +175,10 @@ mod tests {
|
||||
));
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -194,10 +194,10 @@ mod tests {
|
||||
);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -224,10 +224,10 @@ mod tests {
|
||||
app.data.radarr_data.collections.search = Some("Test".into());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SearchCollection,
|
||||
&None,
|
||||
ActiveRadarrBlock::SearchCollection,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -245,10 +245,10 @@ mod tests {
|
||||
);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SearchCollection,
|
||||
&None,
|
||||
ActiveRadarrBlock::SearchCollection,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -277,10 +277,10 @@ mod tests {
|
||||
app.data.radarr_data.collections.filter = Some("Test".into());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::FilterCollections,
|
||||
&None,
|
||||
ActiveRadarrBlock::FilterCollections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -298,10 +298,10 @@ mod tests {
|
||||
);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::FilterCollections,
|
||||
&None,
|
||||
ActiveRadarrBlock::FilterCollections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -326,10 +326,10 @@ mod tests {
|
||||
app.data.radarr_data.collections.sorting(sort_options());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::CollectionsSortPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::CollectionsSortPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -346,10 +346,10 @@ mod tests {
|
||||
);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::CollectionsSortPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::CollectionsSortPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -380,18 +380,18 @@ mod tests {
|
||||
app.data.radarr_data.main_tabs.set_index(1);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.main_tabs.get_active_route(),
|
||||
&ActiveRadarrBlock::Movies.into()
|
||||
ActiveRadarrBlock::Movies.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -401,21 +401,18 @@ mod tests {
|
||||
app.data.radarr_data.main_tabs.set_index(1);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.main_tabs.get_active_route(),
|
||||
&ActiveRadarrBlock::Downloads.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Downloads.into()
|
||||
ActiveRadarrBlock::Downloads.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Downloads.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -425,20 +422,20 @@ mod tests {
|
||||
let mut app = App::default();
|
||||
|
||||
CollectionsHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::UpdateAllCollectionsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::UpdateAllCollectionsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::UpdateAllCollectionsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::UpdateAllCollectionsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -451,10 +448,10 @@ mod tests {
|
||||
app.data.radarr_data.collections.search = Some("Test".into());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SearchCollection,
|
||||
&None,
|
||||
ActiveRadarrBlock::SearchCollection,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -472,10 +469,10 @@ mod tests {
|
||||
);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SearchCollection,
|
||||
&None,
|
||||
ActiveRadarrBlock::SearchCollection,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -499,10 +496,10 @@ mod tests {
|
||||
app.data.radarr_data.collections.filter = Some("Test".into());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::FilterCollections,
|
||||
&None,
|
||||
ActiveRadarrBlock::FilterCollections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -520,10 +517,10 @@ mod tests {
|
||||
);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::FilterCollections,
|
||||
&None,
|
||||
ActiveRadarrBlock::FilterCollections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -560,17 +557,11 @@ mod tests {
|
||||
.collections
|
||||
.set_items(vec![Collection::default()]);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
CollectionsHandler::with(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Collections, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::CollectionDetails.into()
|
||||
ActiveRadarrBlock::CollectionDetails.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -585,17 +576,11 @@ mod tests {
|
||||
.collections
|
||||
.set_items(vec![Collection::default()]);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
CollectionsHandler::with(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Collections, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -615,10 +600,10 @@ mod tests {
|
||||
app.data.radarr_data.collections.search = Some("Test 2".into());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SearchCollection,
|
||||
&None,
|
||||
ActiveRadarrBlock::SearchCollection,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -634,7 +619,7 @@ mod tests {
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -654,10 +639,10 @@ mod tests {
|
||||
app.data.radarr_data.collections.search = Some("Test 5".into());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SearchCollection,
|
||||
&None,
|
||||
ActiveRadarrBlock::SearchCollection,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -673,7 +658,7 @@ mod tests {
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::SearchCollectionError.into()
|
||||
ActiveRadarrBlock::SearchCollectionError.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -693,10 +678,10 @@ mod tests {
|
||||
app.data.radarr_data.collections.search = Some("Test 2".into());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SearchCollection,
|
||||
&None,
|
||||
ActiveRadarrBlock::SearchCollection,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -712,7 +697,7 @@ mod tests {
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -732,10 +717,10 @@ mod tests {
|
||||
app.data.radarr_data.collections.filter = Some("Test".into());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::FilterCollections,
|
||||
&None,
|
||||
ActiveRadarrBlock::FilterCollections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -764,7 +749,7 @@ mod tests {
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -784,10 +769,10 @@ mod tests {
|
||||
app.data.radarr_data.collections.filter = Some("Test 5".into());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::FilterCollections,
|
||||
&None,
|
||||
ActiveRadarrBlock::FilterCollections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -795,7 +780,7 @@ mod tests {
|
||||
assert!(app.data.radarr_data.collections.filtered_items.is_none());
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::FilterCollectionsError.into()
|
||||
ActiveRadarrBlock::FilterCollectionsError.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -812,10 +797,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::UpdateAllCollectionsPrompt.into());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::UpdateAllCollectionsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::UpdateAllCollectionsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -826,7 +811,7 @@ mod tests {
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -842,10 +827,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::UpdateAllCollectionsPrompt.into());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::UpdateAllCollectionsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::UpdateAllCollectionsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -853,7 +838,7 @@ mod tests {
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -875,16 +860,16 @@ mod tests {
|
||||
expected_vec.reverse();
|
||||
|
||||
CollectionsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::CollectionsSortPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::CollectionsSortPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
assert_eq!(app.data.radarr_data.collections.items, expected_vec);
|
||||
}
|
||||
@@ -916,11 +901,11 @@ mod tests {
|
||||
app.data.radarr_data = create_test_radarr_data();
|
||||
app.data.radarr_data.collections.search = Some("Test".into());
|
||||
|
||||
CollectionsHandler::with(&ESC_KEY, &mut app, &active_radarr_block, &None).handle();
|
||||
CollectionsHandler::with(ESC_KEY, &mut app, active_radarr_block, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert_eq!(app.data.radarr_data.collections.search, None);
|
||||
@@ -946,11 +931,11 @@ mod tests {
|
||||
..StatefulTable::default()
|
||||
};
|
||||
|
||||
CollectionsHandler::with(&ESC_KEY, &mut app, &active_radarr_block, &None).handle();
|
||||
CollectionsHandler::with(ESC_KEY, &mut app, active_radarr_block, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert_eq!(app.data.radarr_data.collections.filter, None);
|
||||
@@ -966,16 +951,16 @@ mod tests {
|
||||
app.data.radarr_data.prompt_confirm = true;
|
||||
|
||||
CollectionsHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::UpdateAllCollectionsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::UpdateAllCollectionsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
@@ -987,16 +972,16 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::CollectionsSortPrompt.into());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::CollectionsSortPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::CollectionsSortPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1016,11 +1001,11 @@ mod tests {
|
||||
..StatefulTable::default()
|
||||
};
|
||||
|
||||
CollectionsHandler::with(&ESC_KEY, &mut app, &ActiveRadarrBlock::Collections, &None).handle();
|
||||
CollectionsHandler::with(ESC_KEY, &mut app, ActiveRadarrBlock::Collections, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
assert!(app.error.text.is_empty());
|
||||
assert_eq!(app.data.radarr_data.collections.search, None);
|
||||
@@ -1055,16 +1040,16 @@ mod tests {
|
||||
.set_items(vec![Collection::default()]);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.search.key,
|
||||
DEFAULT_KEYBINDINGS.search.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::SearchCollection.into()
|
||||
ActiveRadarrBlock::SearchCollection.into()
|
||||
);
|
||||
assert!(app.should_ignore_quit_key);
|
||||
assert_eq!(
|
||||
@@ -1085,16 +1070,16 @@ mod tests {
|
||||
.set_items(vec![Collection::default()]);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.search.key,
|
||||
DEFAULT_KEYBINDINGS.search.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert_eq!(app.data.radarr_data.collections.search, None);
|
||||
@@ -1110,16 +1095,16 @@ mod tests {
|
||||
.set_items(vec![Collection::default()]);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.filter.key,
|
||||
DEFAULT_KEYBINDINGS.filter.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::FilterCollections.into()
|
||||
ActiveRadarrBlock::FilterCollections.into()
|
||||
);
|
||||
assert!(app.should_ignore_quit_key);
|
||||
assert!(app.data.radarr_data.collections.filter.is_some());
|
||||
@@ -1137,16 +1122,16 @@ mod tests {
|
||||
.set_items(vec![Collection::default()]);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.filter.key,
|
||||
DEFAULT_KEYBINDINGS.filter.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert!(app.data.radarr_data.collections.filter.is_none());
|
||||
@@ -1166,16 +1151,16 @@ mod tests {
|
||||
app.data.radarr_data.collections.filter = Some("Test".into());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.filter.key,
|
||||
DEFAULT_KEYBINDINGS.filter.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::FilterCollections.into()
|
||||
ActiveRadarrBlock::FilterCollections.into()
|
||||
);
|
||||
assert!(app.should_ignore_quit_key);
|
||||
assert_eq!(
|
||||
@@ -1212,16 +1197,16 @@ mod tests {
|
||||
app.data.radarr_data = radarr_data;
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.edit.key,
|
||||
DEFAULT_KEYBINDINGS.edit.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
assert!(app.data.radarr_data.edit_collection_modal.is_none());
|
||||
}
|
||||
@@ -1236,16 +1221,16 @@ mod tests {
|
||||
.set_items(vec![Collection::default()]);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.update.key,
|
||||
DEFAULT_KEYBINDINGS.update.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::UpdateAllCollectionsPrompt.into()
|
||||
ActiveRadarrBlock::UpdateAllCollectionsPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1261,16 +1246,16 @@ mod tests {
|
||||
.set_items(vec![Collection::default()]);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.update.key,
|
||||
DEFAULT_KEYBINDINGS.update.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1285,16 +1270,16 @@ mod tests {
|
||||
.set_items(vec![Collection::default()]);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.refresh.key,
|
||||
DEFAULT_KEYBINDINGS.refresh.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
assert!(app.should_refresh);
|
||||
}
|
||||
@@ -1311,16 +1296,16 @@ mod tests {
|
||||
.set_items(vec![Collection::default()]);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.refresh.key,
|
||||
DEFAULT_KEYBINDINGS.refresh.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
assert!(!app.should_refresh);
|
||||
}
|
||||
@@ -1336,10 +1321,10 @@ mod tests {
|
||||
app.data.radarr_data.collections.search = Some("Test".into());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
DEFAULT_KEYBINDINGS.backspace.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SearchCollection,
|
||||
&None,
|
||||
ActiveRadarrBlock::SearchCollection,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1367,10 +1352,10 @@ mod tests {
|
||||
app.data.radarr_data.collections.filter = Some("Test".into());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
DEFAULT_KEYBINDINGS.backspace.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::FilterCollections,
|
||||
&None,
|
||||
ActiveRadarrBlock::FilterCollections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1398,10 +1383,10 @@ mod tests {
|
||||
app.data.radarr_data.collections.search = Some(HorizontallyScrollableText::default());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&Key::Char('h'),
|
||||
Key::Char('h'),
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SearchCollection,
|
||||
&None,
|
||||
ActiveRadarrBlock::SearchCollection,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1429,10 +1414,10 @@ mod tests {
|
||||
app.data.radarr_data.collections.filter = Some(HorizontallyScrollableText::default());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&Key::Char('h'),
|
||||
Key::Char('h'),
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::FilterCollections,
|
||||
&None,
|
||||
ActiveRadarrBlock::FilterCollections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1459,16 +1444,16 @@ mod tests {
|
||||
.set_items(vec![Collection::default()]);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.sort.key,
|
||||
DEFAULT_KEYBINDINGS.sort.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::CollectionsSortPrompt.into()
|
||||
ActiveRadarrBlock::CollectionsSortPrompt.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app
|
||||
@@ -1496,16 +1481,16 @@ mod tests {
|
||||
.set_items(vec![Collection::default()]);
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.sort.key,
|
||||
DEFAULT_KEYBINDINGS.sort.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
assert!(app.data.radarr_data.collections.sort.is_none());
|
||||
assert!(!app.data.radarr_data.collections.sort_asc);
|
||||
@@ -1523,10 +1508,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::UpdateAllCollectionsPrompt.into());
|
||||
|
||||
CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.confirm.key,
|
||||
DEFAULT_KEYBINDINGS.confirm.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::UpdateAllCollectionsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::UpdateAllCollectionsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1537,7 +1522,7 @@ mod tests {
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1693,9 +1678,9 @@ mod tests {
|
||||
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if collections_handler_blocks.contains(&active_radarr_block) {
|
||||
assert!(CollectionsHandler::accepts(&active_radarr_block));
|
||||
assert!(CollectionsHandler::accepts(active_radarr_block));
|
||||
} else {
|
||||
assert!(!CollectionsHandler::accepts(&active_radarr_block));
|
||||
assert!(!CollectionsHandler::accepts(active_radarr_block));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1706,10 +1691,10 @@ mod tests {
|
||||
app.is_loading = true;
|
||||
|
||||
let handler = CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -1721,10 +1706,10 @@ mod tests {
|
||||
app.is_loading = false;
|
||||
|
||||
let handler = CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -1741,10 +1726,10 @@ mod tests {
|
||||
.set_items(vec![Collection::default()]);
|
||||
|
||||
let handler = CollectionsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Collections,
|
||||
&None,
|
||||
ActiveRadarrBlock::Collections,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
|
||||
@@ -12,22 +12,22 @@ use crate::{handle_text_box_keys, handle_text_box_left_right_keys};
|
||||
mod edit_collection_handler_tests;
|
||||
|
||||
pub(super) struct EditCollectionHandler<'a, 'b> {
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_radarr_block: &'a ActiveRadarrBlock,
|
||||
context: &'a Option<ActiveRadarrBlock>,
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditCollectionHandler<'a, 'b> {
|
||||
fn accepts(active_block: &'a ActiveRadarrBlock) -> bool {
|
||||
EDIT_COLLECTION_BLOCKS.contains(active_block)
|
||||
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
||||
EDIT_COLLECTION_BLOCKS.contains(&active_block)
|
||||
}
|
||||
|
||||
fn with(
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_block: &'a ActiveRadarrBlock,
|
||||
context: &'a Option<ActiveRadarrBlock>,
|
||||
active_block: ActiveRadarrBlock,
|
||||
context: Option<ActiveRadarrBlock>,
|
||||
) -> EditCollectionHandler<'a, 'b> {
|
||||
EditCollectionHandler {
|
||||
key,
|
||||
@@ -37,7 +37,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditCollectionHandle
|
||||
}
|
||||
}
|
||||
|
||||
fn get_key(&self) -> &Key {
|
||||
fn get_key(&self) -> Key {
|
||||
self.key
|
||||
}
|
||||
|
||||
@@ -203,8 +203,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditCollectionHandle
|
||||
| ActiveRadarrBlock::EditCollectionSelectQualityProfile => {
|
||||
self.app.push_navigation_stack(
|
||||
(
|
||||
*self.app.data.radarr_data.selected_block.get_active_block(),
|
||||
*self.context,
|
||||
self.app.data.radarr_data.selected_block.get_active_block(),
|
||||
self.context,
|
||||
)
|
||||
.into(),
|
||||
)
|
||||
@@ -212,8 +212,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditCollectionHandle
|
||||
ActiveRadarrBlock::EditCollectionRootFolderPathInput => {
|
||||
self.app.push_navigation_stack(
|
||||
(
|
||||
*self.app.data.radarr_data.selected_block.get_active_block(),
|
||||
*self.context,
|
||||
self.app.data.radarr_data.selected_block.get_active_block(),
|
||||
self.context,
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
@@ -308,8 +308,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditCollectionHandle
|
||||
}
|
||||
ActiveRadarrBlock::EditCollectionPrompt => {
|
||||
if self.app.data.radarr_data.selected_block.get_active_block()
|
||||
== &ActiveRadarrBlock::EditCollectionConfirmPrompt
|
||||
&& *key == DEFAULT_KEYBINDINGS.confirm.key
|
||||
== ActiveRadarrBlock::EditCollectionConfirmPrompt
|
||||
&& key == DEFAULT_KEYBINDINGS.confirm.key
|
||||
{
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action = Some(RadarrEvent::EditCollection(None));
|
||||
|
||||
@@ -44,10 +44,10 @@ mod tests {
|
||||
if key == Key::Up {
|
||||
for i in (0..minimum_availability_vec.len()).rev() {
|
||||
EditCollectionHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionSelectMinimumAvailability,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionSelectMinimumAvailability,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -66,10 +66,10 @@ mod tests {
|
||||
} else {
|
||||
for i in 0..minimum_availability_vec.len() {
|
||||
EditCollectionHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionSelectMinimumAvailability,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionSelectMinimumAvailability,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -104,10 +104,10 @@ mod tests {
|
||||
.set_items(vec!["Test 1".to_owned(), "Test 2".to_owned()]);
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionSelectQualityProfile,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionSelectQualityProfile,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -124,10 +124,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionSelectQualityProfile,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionSelectQualityProfile,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -152,23 +152,18 @@ mod tests {
|
||||
BlockSelectionState::new(&EDIT_COLLECTION_SELECTION_BLOCKS);
|
||||
app.data.radarr_data.selected_block.next();
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionPrompt,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
EditCollectionHandler::with(key, &mut app, ActiveRadarrBlock::EditCollectionPrompt, None)
|
||||
.handle();
|
||||
|
||||
if key == Key::Up {
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::EditCollectionToggleMonitored
|
||||
ActiveRadarrBlock::EditCollectionToggleMonitored
|
||||
);
|
||||
} else {
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::EditCollectionSelectQualityProfile
|
||||
ActiveRadarrBlock::EditCollectionSelectQualityProfile
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -184,17 +179,12 @@ mod tests {
|
||||
BlockSelectionState::new(&EDIT_COLLECTION_SELECTION_BLOCKS);
|
||||
app.data.radarr_data.selected_block.next();
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionPrompt,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
EditCollectionHandler::with(key, &mut app, ActiveRadarrBlock::EditCollectionPrompt, None)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::EditCollectionSelectMinimumAvailability
|
||||
ActiveRadarrBlock::EditCollectionSelectMinimumAvailability
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -224,10 +214,10 @@ mod tests {
|
||||
.set_items(minimum_availability_vec.clone());
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionSelectMinimumAvailability,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionSelectMinimumAvailability,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -244,10 +234,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionSelectMinimumAvailability,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionSelectMinimumAvailability,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -282,10 +272,10 @@ mod tests {
|
||||
]);
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionSelectQualityProfile,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionSelectQualityProfile,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -302,10 +292,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionSelectQualityProfile,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionSelectQualityProfile,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -331,10 +321,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionRootFolderPathInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionRootFolderPathInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -352,10 +342,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionRootFolderPathInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionRootFolderPathInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -386,23 +376,13 @@ mod tests {
|
||||
fn test_left_right_prompt_toggle(#[values(Key::Left, Key::Right)] key: Key) {
|
||||
let mut app = App::default();
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionPrompt,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
EditCollectionHandler::with(key, &mut app, ActiveRadarrBlock::EditCollectionPrompt, None)
|
||||
.handle();
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionPrompt,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
EditCollectionHandler::with(key, &mut app, ActiveRadarrBlock::EditCollectionPrompt, None)
|
||||
.handle();
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
@@ -416,10 +396,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionRootFolderPathInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionRootFolderPathInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -437,10 +417,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionRootFolderPathInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionRootFolderPathInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -484,10 +464,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditCollectionRootFolderPathInput.into());
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionRootFolderPathInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionRootFolderPathInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -503,7 +483,7 @@ mod tests {
|
||||
.is_empty());
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditCollectionPrompt.into()
|
||||
ActiveRadarrBlock::EditCollectionPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -522,16 +502,16 @@ mod tests {
|
||||
.set_index(EDIT_COLLECTION_SELECTION_BLOCKS.len() - 1);
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
}
|
||||
@@ -552,16 +532,16 @@ mod tests {
|
||||
.set_index(EDIT_COLLECTION_SELECTION_BLOCKS.len() - 1);
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
@@ -587,16 +567,16 @@ mod tests {
|
||||
.set_index(EDIT_COLLECTION_SELECTION_BLOCKS.len() - 1);
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditCollectionPrompt.into()
|
||||
ActiveRadarrBlock::EditCollectionPrompt.into()
|
||||
);
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
assert!(!app.should_refresh);
|
||||
@@ -615,14 +595,14 @@ mod tests {
|
||||
app.push_navigation_stack(current_route);
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionPrompt,
|
||||
&Some(ActiveRadarrBlock::Collections),
|
||||
ActiveRadarrBlock::EditCollectionPrompt,
|
||||
Some(ActiveRadarrBlock::Collections),
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), ¤t_route);
|
||||
assert_eq!(app.get_current_route(), current_route);
|
||||
assert_eq!(
|
||||
app
|
||||
.data
|
||||
@@ -635,14 +615,14 @@ mod tests {
|
||||
);
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionPrompt,
|
||||
&Some(ActiveRadarrBlock::Collections),
|
||||
ActiveRadarrBlock::EditCollectionPrompt,
|
||||
Some(ActiveRadarrBlock::Collections),
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), ¤t_route);
|
||||
assert_eq!(app.get_current_route(), current_route);
|
||||
assert_eq!(
|
||||
app
|
||||
.data
|
||||
@@ -673,14 +653,14 @@ mod tests {
|
||||
app.push_navigation_stack(current_route);
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionPrompt,
|
||||
&Some(ActiveRadarrBlock::Collections),
|
||||
ActiveRadarrBlock::EditCollectionPrompt,
|
||||
Some(ActiveRadarrBlock::Collections),
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), ¤t_route);
|
||||
assert_eq!(app.get_current_route(), current_route);
|
||||
assert_eq!(
|
||||
app
|
||||
.data
|
||||
@@ -693,14 +673,14 @@ mod tests {
|
||||
);
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionPrompt,
|
||||
&Some(ActiveRadarrBlock::Collections),
|
||||
ActiveRadarrBlock::EditCollectionPrompt,
|
||||
Some(ActiveRadarrBlock::Collections),
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), ¤t_route);
|
||||
assert_eq!(app.get_current_route(), current_route);
|
||||
assert_eq!(
|
||||
app
|
||||
.data
|
||||
@@ -735,16 +715,16 @@ mod tests {
|
||||
app.data.radarr_data.selected_block.set_index(index);
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionPrompt,
|
||||
&Some(ActiveRadarrBlock::Collections),
|
||||
ActiveRadarrBlock::EditCollectionPrompt,
|
||||
Some(ActiveRadarrBlock::Collections),
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&(selected_block, Some(ActiveRadarrBlock::Collections)).into()
|
||||
(selected_block, Some(ActiveRadarrBlock::Collections)).into()
|
||||
);
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
|
||||
@@ -768,16 +748,16 @@ mod tests {
|
||||
app.push_navigation_stack(active_radarr_block.into());
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&Some(ActiveRadarrBlock::Collections),
|
||||
active_radarr_block,
|
||||
Some(ActiveRadarrBlock::Collections),
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditCollectionPrompt.into()
|
||||
ActiveRadarrBlock::EditCollectionPrompt.into()
|
||||
);
|
||||
|
||||
if active_radarr_block == ActiveRadarrBlock::EditCollectionRootFolderPathInput {
|
||||
@@ -806,17 +786,17 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditCollectionRootFolderPathInput.into());
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionRootFolderPathInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionRootFolderPathInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditCollectionPrompt.into()
|
||||
ActiveRadarrBlock::EditCollectionPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -828,16 +808,16 @@ mod tests {
|
||||
app.data.radarr_data = create_test_radarr_data();
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
let radarr_data = &app.data.radarr_data;
|
||||
|
||||
@@ -860,11 +840,11 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Collections.into());
|
||||
app.push_navigation_stack(active_radarr_block.into());
|
||||
|
||||
EditCollectionHandler::with(&ESC_KEY, &mut app, &active_radarr_block, &None).handle();
|
||||
EditCollectionHandler::with(ESC_KEY, &mut app, active_radarr_block, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -890,10 +870,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
DEFAULT_KEYBINDINGS.backspace.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionRootFolderPathInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionRootFolderPathInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -916,10 +896,10 @@ mod tests {
|
||||
app.data.radarr_data.edit_collection_modal = Some(EditCollectionModal::default());
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&Key::Char('h'),
|
||||
Key::Char('h'),
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionRootFolderPathInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionRootFolderPathInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -951,16 +931,16 @@ mod tests {
|
||||
.set_index(EDIT_COLLECTION_SELECTION_BLOCKS.len() - 1);
|
||||
|
||||
EditCollectionHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.confirm.key,
|
||||
DEFAULT_KEYBINDINGS.confirm.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
@@ -974,9 +954,9 @@ mod tests {
|
||||
fn test_edit_collection_handler_accepts() {
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if EDIT_COLLECTION_BLOCKS.contains(&active_radarr_block) {
|
||||
assert!(EditCollectionHandler::accepts(&active_radarr_block));
|
||||
assert!(EditCollectionHandler::accepts(active_radarr_block));
|
||||
} else {
|
||||
assert!(!EditCollectionHandler::accepts(&active_radarr_block));
|
||||
assert!(!EditCollectionHandler::accepts(active_radarr_block));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -987,10 +967,10 @@ mod tests {
|
||||
app.is_loading = true;
|
||||
|
||||
let handler = EditCollectionHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionPrompt,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -1002,10 +982,10 @@ mod tests {
|
||||
app.is_loading = false;
|
||||
|
||||
let handler = EditCollectionHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionPrompt,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -1018,10 +998,10 @@ mod tests {
|
||||
app.data.radarr_data.edit_collection_modal = Some(EditCollectionModal::default());
|
||||
|
||||
let handler = EditCollectionHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditCollectionPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditCollectionPrompt,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
|
||||
@@ -22,10 +22,10 @@ mod edit_collection_handler;
|
||||
mod collections_handler_tests;
|
||||
|
||||
pub(super) struct CollectionsHandler<'a, 'b> {
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_radarr_block: &'a ActiveRadarrBlock,
|
||||
context: &'a Option<ActiveRadarrBlock>,
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'a, 'b> {
|
||||
@@ -43,17 +43,17 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'
|
||||
}
|
||||
}
|
||||
|
||||
fn accepts(active_block: &'a ActiveRadarrBlock) -> bool {
|
||||
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
||||
CollectionDetailsHandler::accepts(active_block)
|
||||
|| EditCollectionHandler::accepts(active_block)
|
||||
|| COLLECTIONS_BLOCKS.contains(active_block)
|
||||
|| COLLECTIONS_BLOCKS.contains(&active_block)
|
||||
}
|
||||
|
||||
fn with(
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_block: &'a ActiveRadarrBlock,
|
||||
context: &'a Option<ActiveRadarrBlock>,
|
||||
active_block: ActiveRadarrBlock,
|
||||
context: Option<ActiveRadarrBlock>,
|
||||
) -> CollectionsHandler<'a, 'b> {
|
||||
CollectionsHandler {
|
||||
key,
|
||||
@@ -63,7 +63,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'
|
||||
}
|
||||
}
|
||||
|
||||
fn get_key(&self) -> &Key {
|
||||
fn get_key(&self) -> Key {
|
||||
self.key
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'
|
||||
let key = self.key;
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::Collections => match self.key {
|
||||
_ if *key == DEFAULT_KEYBINDINGS.search.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.search.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::SearchCollection.into());
|
||||
@@ -314,7 +314,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'
|
||||
Some(HorizontallyScrollableText::default());
|
||||
self.app.should_ignore_quit_key = true;
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.filter.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.filter.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::FilterCollections.into());
|
||||
@@ -323,7 +323,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'
|
||||
Some(HorizontallyScrollableText::default());
|
||||
self.app.should_ignore_quit_key = true;
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.edit.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.edit.key => {
|
||||
self.app.push_navigation_stack(
|
||||
(
|
||||
ActiveRadarrBlock::EditCollectionPrompt,
|
||||
@@ -336,15 +336,15 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'
|
||||
self.app.data.radarr_data.selected_block =
|
||||
BlockSelectionState::new(&EDIT_COLLECTION_SELECTION_BLOCKS);
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.update.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.update.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::UpdateAllCollectionsPrompt.into());
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||
self.app.should_refresh = true;
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.sort.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.sort.key => {
|
||||
self
|
||||
.app
|
||||
.data
|
||||
@@ -386,7 +386,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'
|
||||
)
|
||||
}
|
||||
ActiveRadarrBlock::UpdateAllCollectionsPrompt => {
|
||||
if *key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
if key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action = Some(RadarrEvent::UpdateCollections);
|
||||
|
||||
|
||||
@@ -44,14 +44,14 @@ mod tests {
|
||||
.downloads
|
||||
.set_items(simple_stateful_iterable_vec!(DownloadRecord));
|
||||
|
||||
DownloadsHandler::with(&key, &mut app, &ActiveRadarrBlock::Downloads, &None).handle();
|
||||
DownloadsHandler::with(key, &mut app, ActiveRadarrBlock::Downloads, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.downloads.current_selection().title,
|
||||
"Test 1"
|
||||
);
|
||||
|
||||
DownloadsHandler::with(&key, &mut app, &ActiveRadarrBlock::Downloads, &None).handle();
|
||||
DownloadsHandler::with(key, &mut app, ActiveRadarrBlock::Downloads, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.downloads.current_selection().title,
|
||||
@@ -87,10 +87,10 @@ mod tests {
|
||||
.set_items(extended_stateful_iterable_vec!(DownloadRecord));
|
||||
|
||||
DownloadsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Downloads,
|
||||
&None,
|
||||
ActiveRadarrBlock::Downloads,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -100,10 +100,10 @@ mod tests {
|
||||
);
|
||||
|
||||
DownloadsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Downloads,
|
||||
&None,
|
||||
ActiveRadarrBlock::Downloads,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -130,11 +130,11 @@ mod tests {
|
||||
.downloads
|
||||
.set_items(vec![DownloadRecord::default()]);
|
||||
|
||||
DownloadsHandler::with(&DELETE_KEY, &mut app, &ActiveRadarrBlock::Downloads, &None).handle();
|
||||
DownloadsHandler::with(DELETE_KEY, &mut app, ActiveRadarrBlock::Downloads, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::DeleteDownloadPrompt.into()
|
||||
ActiveRadarrBlock::DeleteDownloadPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -149,12 +149,9 @@ mod tests {
|
||||
.downloads
|
||||
.set_items(vec![DownloadRecord::default()]);
|
||||
|
||||
DownloadsHandler::with(&DELETE_KEY, &mut app, &ActiveRadarrBlock::Downloads, &None).handle();
|
||||
DownloadsHandler::with(DELETE_KEY, &mut app, ActiveRadarrBlock::Downloads, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Downloads.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Downloads.into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,20 +168,20 @@ mod tests {
|
||||
app.data.radarr_data.main_tabs.set_index(2);
|
||||
|
||||
DownloadsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Downloads,
|
||||
&None,
|
||||
ActiveRadarrBlock::Downloads,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.main_tabs.get_active_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -195,21 +192,18 @@ mod tests {
|
||||
app.data.radarr_data.main_tabs.set_index(2);
|
||||
|
||||
DownloadsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Downloads,
|
||||
&None,
|
||||
ActiveRadarrBlock::Downloads,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.main_tabs.get_active_route(),
|
||||
&ActiveRadarrBlock::Blocklist.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Blocklist.into()
|
||||
ActiveRadarrBlock::Blocklist.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Blocklist.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -223,11 +217,11 @@ mod tests {
|
||||
) {
|
||||
let mut app = App::default();
|
||||
|
||||
DownloadsHandler::with(&key, &mut app, &active_radarr_block, &None).handle();
|
||||
DownloadsHandler::with(key, &mut app, active_radarr_block, None).handle();
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
DownloadsHandler::with(&key, &mut app, &active_radarr_block, &None).handle();
|
||||
DownloadsHandler::with(key, &mut app, active_radarr_block, None).handle();
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
@@ -269,14 +263,14 @@ mod tests {
|
||||
app.push_navigation_stack(base_route.into());
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
|
||||
DownloadsHandler::with(&SUBMIT_KEY, &mut app, &prompt_block, &None).handle();
|
||||
DownloadsHandler::with(SUBMIT_KEY, &mut app, prompt_block, None).handle();
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
assert_eq!(
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
Some(expected_action)
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &base_route.into());
|
||||
assert_eq!(app.get_current_route(), base_route.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -295,11 +289,11 @@ mod tests {
|
||||
app.push_navigation_stack(base_route.into());
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
|
||||
DownloadsHandler::with(&SUBMIT_KEY, &mut app, &prompt_block, &None).handle();
|
||||
DownloadsHandler::with(SUBMIT_KEY, &mut app, prompt_block, None).handle();
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
assert_eq!(app.get_current_route(), &base_route.into());
|
||||
assert_eq!(app.get_current_route(), base_route.into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,9 +317,9 @@ mod tests {
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
app.data.radarr_data.prompt_confirm = true;
|
||||
|
||||
DownloadsHandler::with(&ESC_KEY, &mut app, &prompt_block, &None).handle();
|
||||
DownloadsHandler::with(ESC_KEY, &mut app, prompt_block, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &base_block.into());
|
||||
assert_eq!(app.get_current_route(), base_block.into());
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
|
||||
@@ -337,12 +331,9 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Downloads.into());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Downloads.into());
|
||||
|
||||
DownloadsHandler::with(&ESC_KEY, &mut app, &ActiveRadarrBlock::Downloads, &None).handle();
|
||||
DownloadsHandler::with(ESC_KEY, &mut app, ActiveRadarrBlock::Downloads, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Downloads.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Downloads.into());
|
||||
assert!(app.error.text.is_empty());
|
||||
}
|
||||
}
|
||||
@@ -365,16 +356,16 @@ mod tests {
|
||||
.set_items(vec![DownloadRecord::default()]);
|
||||
|
||||
DownloadsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.update.key,
|
||||
DEFAULT_KEYBINDINGS.update.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Downloads,
|
||||
&None,
|
||||
ActiveRadarrBlock::Downloads,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::UpdateDownloadsPrompt.into()
|
||||
ActiveRadarrBlock::UpdateDownloadsPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -390,17 +381,14 @@ mod tests {
|
||||
.set_items(vec![DownloadRecord::default()]);
|
||||
|
||||
DownloadsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.update.key,
|
||||
DEFAULT_KEYBINDINGS.update.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Downloads,
|
||||
&None,
|
||||
ActiveRadarrBlock::Downloads,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Downloads.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Downloads.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -414,17 +402,14 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Downloads.into());
|
||||
|
||||
DownloadsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.refresh.key,
|
||||
DEFAULT_KEYBINDINGS.refresh.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Downloads,
|
||||
&None,
|
||||
ActiveRadarrBlock::Downloads,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Downloads.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Downloads.into());
|
||||
assert!(app.should_refresh);
|
||||
}
|
||||
|
||||
@@ -440,17 +425,14 @@ mod tests {
|
||||
.set_items(vec![DownloadRecord::default()]);
|
||||
|
||||
DownloadsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.refresh.key,
|
||||
DEFAULT_KEYBINDINGS.refresh.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Downloads,
|
||||
&None,
|
||||
ActiveRadarrBlock::Downloads,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Downloads.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Downloads.into());
|
||||
assert!(!app.should_refresh);
|
||||
}
|
||||
|
||||
@@ -480,10 +462,10 @@ mod tests {
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
|
||||
DownloadsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.confirm.key,
|
||||
DEFAULT_KEYBINDINGS.confirm.key,
|
||||
&mut app,
|
||||
&prompt_block,
|
||||
&None,
|
||||
prompt_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -492,7 +474,7 @@ mod tests {
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
Some(expected_action)
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &base_route.into());
|
||||
assert_eq!(app.get_current_route(), base_route.into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -500,9 +482,9 @@ mod tests {
|
||||
fn test_downloads_handler_accepts() {
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if DOWNLOADS_BLOCKS.contains(&active_radarr_block) {
|
||||
assert!(DownloadsHandler::accepts(&active_radarr_block));
|
||||
assert!(DownloadsHandler::accepts(active_radarr_block));
|
||||
} else {
|
||||
assert!(!DownloadsHandler::accepts(&active_radarr_block));
|
||||
assert!(!DownloadsHandler::accepts(active_radarr_block));
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -513,10 +495,10 @@ mod tests {
|
||||
app.is_loading = true;
|
||||
|
||||
let handler = DownloadsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Downloads,
|
||||
&None,
|
||||
ActiveRadarrBlock::Downloads,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -528,10 +510,10 @@ mod tests {
|
||||
app.is_loading = false;
|
||||
|
||||
let handler = DownloadsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Downloads,
|
||||
&None,
|
||||
ActiveRadarrBlock::Downloads,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -548,10 +530,10 @@ mod tests {
|
||||
.downloads
|
||||
.set_items(vec![DownloadRecord::default()]);
|
||||
let handler = DownloadsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Downloads,
|
||||
&None,
|
||||
ActiveRadarrBlock::Downloads,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
|
||||
@@ -12,22 +12,22 @@ use crate::network::radarr_network::RadarrEvent;
|
||||
mod downloads_handler_tests;
|
||||
|
||||
pub(super) struct DownloadsHandler<'a, 'b> {
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_radarr_block: &'a ActiveRadarrBlock,
|
||||
_context: &'a Option<ActiveRadarrBlock>,
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DownloadsHandler<'a, 'b> {
|
||||
fn accepts(active_block: &'a ActiveRadarrBlock) -> bool {
|
||||
DOWNLOADS_BLOCKS.contains(active_block)
|
||||
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
||||
DOWNLOADS_BLOCKS.contains(&active_block)
|
||||
}
|
||||
|
||||
fn with(
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_block: &'a ActiveRadarrBlock,
|
||||
_context: &'a Option<ActiveRadarrBlock>,
|
||||
active_block: ActiveRadarrBlock,
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
) -> DownloadsHandler<'a, 'b> {
|
||||
DownloadsHandler {
|
||||
key,
|
||||
@@ -37,7 +37,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DownloadsHandler<'a,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_key(&self) -> &Key {
|
||||
fn get_key(&self) -> Key {
|
||||
self.key
|
||||
}
|
||||
|
||||
@@ -46,31 +46,31 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DownloadsHandler<'a,
|
||||
}
|
||||
|
||||
fn handle_scroll_up(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::Downloads {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::Downloads {
|
||||
self.app.data.radarr_data.downloads.scroll_up()
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_scroll_down(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::Downloads {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::Downloads {
|
||||
self.app.data.radarr_data.downloads.scroll_down()
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_home(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::Downloads {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::Downloads {
|
||||
self.app.data.radarr_data.downloads.scroll_to_top()
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_end(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::Downloads {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::Downloads {
|
||||
self.app.data.radarr_data.downloads.scroll_to_bottom()
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_delete(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::Downloads {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::Downloads {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::DeleteDownloadPrompt.into())
|
||||
@@ -121,18 +121,18 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DownloadsHandler<'a,
|
||||
let key = self.key;
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::Downloads => match self.key {
|
||||
_ if *key == DEFAULT_KEYBINDINGS.update.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.update.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::UpdateDownloadsPrompt.into());
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||
self.app.should_refresh = true;
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
ActiveRadarrBlock::DeleteDownloadPrompt => {
|
||||
if *key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
if key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action = Some(RadarrEvent::DeleteDownload(None));
|
||||
|
||||
@@ -140,7 +140,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DownloadsHandler<'a,
|
||||
}
|
||||
}
|
||||
ActiveRadarrBlock::UpdateDownloadsPrompt => {
|
||||
if *key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
if key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action = Some(RadarrEvent::UpdateDownloads);
|
||||
|
||||
|
||||
@@ -11,22 +11,22 @@ use crate::{handle_text_box_keys, handle_text_box_left_right_keys};
|
||||
mod edit_indexer_handler_tests;
|
||||
|
||||
pub(super) struct EditIndexerHandler<'a, 'b> {
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_radarr_block: &'a ActiveRadarrBlock,
|
||||
_context: &'a Option<ActiveRadarrBlock>,
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditIndexerHandler<'a, 'b> {
|
||||
fn accepts(active_block: &'a ActiveRadarrBlock) -> bool {
|
||||
EDIT_INDEXER_BLOCKS.contains(active_block)
|
||||
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
||||
EDIT_INDEXER_BLOCKS.contains(&active_block)
|
||||
}
|
||||
|
||||
fn with(
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_block: &'a ActiveRadarrBlock,
|
||||
_context: &'a Option<ActiveRadarrBlock>,
|
||||
active_block: ActiveRadarrBlock,
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
) -> EditIndexerHandler<'a, 'b> {
|
||||
EditIndexerHandler {
|
||||
key,
|
||||
@@ -36,7 +36,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditIndexerHandler<'
|
||||
}
|
||||
}
|
||||
|
||||
fn get_key(&self) -> &Key {
|
||||
fn get_key(&self) -> Key {
|
||||
self.key
|
||||
}
|
||||
|
||||
@@ -45,13 +45,13 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditIndexerHandler<'
|
||||
}
|
||||
|
||||
fn handle_scroll_up(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::EditIndexerPrompt {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::EditIndexerPrompt {
|
||||
self.app.data.radarr_data.selected_block.previous();
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_scroll_down(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::EditIndexerPrompt {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::EditIndexerPrompt {
|
||||
self.app.data.radarr_data.selected_block.next();
|
||||
}
|
||||
}
|
||||
@@ -184,7 +184,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditIndexerHandler<'
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::EditIndexerPrompt => {
|
||||
if self.app.data.radarr_data.selected_block.get_active_block()
|
||||
== &ActiveRadarrBlock::EditIndexerConfirmPrompt
|
||||
== ActiveRadarrBlock::EditIndexerConfirmPrompt
|
||||
{
|
||||
handle_prompt_toggle(self.app, self.key);
|
||||
} else {
|
||||
@@ -270,7 +270,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditIndexerHandler<'
|
||||
fn handle_submit(&mut self) {
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::EditIndexerPrompt => {
|
||||
let selected_block = *self.app.data.radarr_data.selected_block.get_active_block();
|
||||
let selected_block = self.app.data.radarr_data.selected_block.get_active_block();
|
||||
match selected_block {
|
||||
ActiveRadarrBlock::EditIndexerConfirmPrompt => {
|
||||
let radarr_data = &mut self.app.data.radarr_data;
|
||||
@@ -431,8 +431,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditIndexerHandler<'
|
||||
}
|
||||
ActiveRadarrBlock::EditIndexerPrompt => {
|
||||
if self.app.data.radarr_data.selected_block.get_active_block()
|
||||
== &ActiveRadarrBlock::EditIndexerConfirmPrompt
|
||||
&& *self.key == DEFAULT_KEYBINDINGS.confirm.key
|
||||
== ActiveRadarrBlock::EditIndexerConfirmPrompt
|
||||
&& self.key == DEFAULT_KEYBINDINGS.confirm.key
|
||||
{
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action = Some(RadarrEvent::EditIndexer(None));
|
||||
|
||||
@@ -28,18 +28,17 @@ mod tests {
|
||||
BlockSelectionState::new(&EDIT_INDEXER_TORRENT_SELECTION_BLOCKS);
|
||||
app.data.radarr_data.selected_block.next();
|
||||
|
||||
EditIndexerHandler::with(&key, &mut app, &ActiveRadarrBlock::EditIndexerPrompt, &None)
|
||||
.handle();
|
||||
EditIndexerHandler::with(key, &mut app, ActiveRadarrBlock::EditIndexerPrompt, None).handle();
|
||||
|
||||
if key == Key::Up {
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::EditIndexerNameInput
|
||||
ActiveRadarrBlock::EditIndexerNameInput
|
||||
);
|
||||
} else {
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::EditIndexerToggleEnableAutomaticSearch
|
||||
ActiveRadarrBlock::EditIndexerToggleEnableAutomaticSearch
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -55,12 +54,11 @@ mod tests {
|
||||
BlockSelectionState::new(&EDIT_INDEXER_TORRENT_SELECTION_BLOCKS);
|
||||
app.data.radarr_data.selected_block.next();
|
||||
|
||||
EditIndexerHandler::with(&key, &mut app, &ActiveRadarrBlock::EditIndexerPrompt, &None)
|
||||
.handle();
|
||||
EditIndexerHandler::with(key, &mut app, ActiveRadarrBlock::EditIndexerPrompt, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::EditIndexerToggleEnableRss
|
||||
ActiveRadarrBlock::EditIndexerToggleEnableRss
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -83,10 +81,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerNameInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerNameInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -104,10 +102,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerNameInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerNameInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -134,10 +132,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerUrlInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerUrlInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -155,10 +153,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerUrlInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerUrlInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -185,10 +183,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerApiKeyInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerApiKeyInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -206,10 +204,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerApiKeyInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerApiKeyInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -236,10 +234,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerSeedRatioInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerSeedRatioInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -257,10 +255,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerSeedRatioInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerSeedRatioInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -287,10 +285,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -308,10 +306,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -351,13 +349,11 @@ mod tests {
|
||||
BlockSelectionState::new(&EDIT_INDEXER_TORRENT_SELECTION_BLOCKS);
|
||||
app.data.radarr_data.selected_block.index = EDIT_INDEXER_TORRENT_SELECTION_BLOCKS.len() - 1;
|
||||
|
||||
EditIndexerHandler::with(&key, &mut app, &ActiveRadarrBlock::EditIndexerPrompt, &None)
|
||||
.handle();
|
||||
EditIndexerHandler::with(key, &mut app, ActiveRadarrBlock::EditIndexerPrompt, None).handle();
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
EditIndexerHandler::with(&key, &mut app, &ActiveRadarrBlock::EditIndexerPrompt, &None)
|
||||
.handle();
|
||||
EditIndexerHandler::with(key, &mut app, ActiveRadarrBlock::EditIndexerPrompt, None).handle();
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
@@ -396,23 +392,21 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&left_block
|
||||
left_block
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(&key, &mut app, &ActiveRadarrBlock::EditIndexerPrompt, &None)
|
||||
.handle();
|
||||
EditIndexerHandler::with(key, &mut app, ActiveRadarrBlock::EditIndexerPrompt, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&right_block
|
||||
right_block
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(&key, &mut app, &ActiveRadarrBlock::EditIndexerPrompt, &None)
|
||||
.handle();
|
||||
EditIndexerHandler::with(key, &mut app, ActiveRadarrBlock::EditIndexerPrompt, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&left_block
|
||||
left_block
|
||||
);
|
||||
}
|
||||
|
||||
@@ -445,23 +439,21 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&left_block
|
||||
left_block
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(&key, &mut app, &ActiveRadarrBlock::EditIndexerPrompt, &None)
|
||||
.handle();
|
||||
EditIndexerHandler::with(key, &mut app, ActiveRadarrBlock::EditIndexerPrompt, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&right_block
|
||||
right_block
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(&key, &mut app, &ActiveRadarrBlock::EditIndexerPrompt, &None)
|
||||
.handle();
|
||||
EditIndexerHandler::with(key, &mut app, ActiveRadarrBlock::EditIndexerPrompt, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&left_block
|
||||
left_block
|
||||
);
|
||||
}
|
||||
|
||||
@@ -477,23 +469,21 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::EditIndexerToggleEnableInteractiveSearch
|
||||
ActiveRadarrBlock::EditIndexerToggleEnableInteractiveSearch
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(&key, &mut app, &ActiveRadarrBlock::EditIndexerPrompt, &None)
|
||||
.handle();
|
||||
EditIndexerHandler::with(key, &mut app, ActiveRadarrBlock::EditIndexerPrompt, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::EditIndexerConfirmPrompt
|
||||
ActiveRadarrBlock::EditIndexerConfirmPrompt
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(&key, &mut app, &ActiveRadarrBlock::EditIndexerPrompt, &None)
|
||||
.handle();
|
||||
EditIndexerHandler::with(key, &mut app, ActiveRadarrBlock::EditIndexerPrompt, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::EditIndexerConfirmPrompt
|
||||
ActiveRadarrBlock::EditIndexerConfirmPrompt
|
||||
);
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
@@ -507,10 +497,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerNameInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerNameInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -528,10 +518,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerNameInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerNameInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -558,10 +548,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerUrlInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerUrlInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -579,10 +569,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerUrlInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerUrlInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -609,10 +599,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerApiKeyInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerApiKeyInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -630,10 +620,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerApiKeyInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerApiKeyInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -660,10 +650,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerSeedRatioInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerSeedRatioInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -681,10 +671,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerSeedRatioInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerSeedRatioInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -711,10 +701,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -732,10 +722,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -784,14 +774,14 @@ mod tests {
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
assert!(!app.should_refresh);
|
||||
assert_eq!(app.data.radarr_data.edit_indexer_modal, None);
|
||||
@@ -813,14 +803,14 @@ mod tests {
|
||||
app.data.radarr_data.prompt_confirm = true;
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert!(app.data.radarr_data.edit_indexer_modal.is_some());
|
||||
assert!(app.should_refresh);
|
||||
assert_eq!(
|
||||
@@ -839,16 +829,16 @@ mod tests {
|
||||
app.data.radarr_data.prompt_confirm = true;
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
);
|
||||
assert!(app.data.radarr_data.edit_indexer_modal.is_some());
|
||||
assert!(!app.should_refresh);
|
||||
@@ -877,14 +867,14 @@ mod tests {
|
||||
.set_index(starting_index);
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &block.into());
|
||||
assert_eq!(app.get_current_route(), block.into());
|
||||
assert!(app.should_ignore_quit_key);
|
||||
}
|
||||
|
||||
@@ -898,16 +888,16 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditIndexerPrompt.into());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
);
|
||||
assert!(app
|
||||
.data
|
||||
@@ -919,16 +909,16 @@ mod tests {
|
||||
.unwrap());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
);
|
||||
assert!(!app
|
||||
.data
|
||||
@@ -950,16 +940,16 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditIndexerPrompt.into());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
);
|
||||
assert!(app
|
||||
.data
|
||||
@@ -971,16 +961,16 @@ mod tests {
|
||||
.unwrap());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
);
|
||||
assert!(!app
|
||||
.data
|
||||
@@ -1002,16 +992,16 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditIndexerPrompt.into());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
);
|
||||
assert!(app
|
||||
.data
|
||||
@@ -1023,16 +1013,16 @@ mod tests {
|
||||
.unwrap());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
);
|
||||
assert!(!app
|
||||
.data
|
||||
@@ -1056,10 +1046,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditIndexerNameInput.into());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerNameInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerNameInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1075,7 +1065,7 @@ mod tests {
|
||||
.is_empty());
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1091,10 +1081,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditIndexerUrlInput.into());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerUrlInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerUrlInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1110,7 +1100,7 @@ mod tests {
|
||||
.is_empty());
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1126,10 +1116,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditIndexerApiKeyInput.into());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerApiKeyInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerApiKeyInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1145,7 +1135,7 @@ mod tests {
|
||||
.is_empty());
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1161,10 +1151,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditIndexerSeedRatioInput.into());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerSeedRatioInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerSeedRatioInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1180,7 +1170,7 @@ mod tests {
|
||||
.is_empty());
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1196,10 +1186,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditIndexerTagsInput.into());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1215,7 +1205,7 @@ mod tests {
|
||||
.is_empty());
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1239,14 +1229,14 @@ mod tests {
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
assert_eq!(app.data.radarr_data.edit_indexer_modal, None);
|
||||
}
|
||||
@@ -1268,9 +1258,9 @@ mod tests {
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
app.should_ignore_quit_key = true;
|
||||
|
||||
EditIndexerHandler::with(&ESC_KEY, &mut app, &active_radarr_block, &None).handle();
|
||||
EditIndexerHandler::with(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_eq!(
|
||||
app.data.radarr_data.edit_indexer_modal,
|
||||
@@ -1298,10 +1288,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
DEFAULT_KEYBINDINGS.backspace.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerNameInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerNameInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1327,10 +1317,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
DEFAULT_KEYBINDINGS.backspace.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerUrlInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerUrlInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1356,10 +1346,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
DEFAULT_KEYBINDINGS.backspace.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerApiKeyInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerApiKeyInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1385,10 +1375,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
DEFAULT_KEYBINDINGS.backspace.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerSeedRatioInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerSeedRatioInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1414,10 +1404,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
DEFAULT_KEYBINDINGS.backspace.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1440,10 +1430,10 @@ mod tests {
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&Key::Char('h'),
|
||||
Key::Char('h'),
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerNameInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerNameInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1466,10 +1456,10 @@ mod tests {
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&Key::Char('h'),
|
||||
Key::Char('h'),
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerUrlInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerUrlInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1492,10 +1482,10 @@ mod tests {
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&Key::Char('h'),
|
||||
Key::Char('h'),
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerApiKeyInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerApiKeyInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1518,10 +1508,10 @@ mod tests {
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&Key::Char('h'),
|
||||
Key::Char('h'),
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerSeedRatioInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerSeedRatioInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1544,10 +1534,10 @@ mod tests {
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&Key::Char('h'),
|
||||
Key::Char('h'),
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1579,14 +1569,14 @@ mod tests {
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
|
||||
EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.confirm.key,
|
||||
DEFAULT_KEYBINDINGS.confirm.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert!(app.data.radarr_data.edit_indexer_modal.is_some());
|
||||
assert!(app.should_refresh);
|
||||
assert_eq!(
|
||||
@@ -1600,9 +1590,9 @@ mod tests {
|
||||
fn test_indexer_settings_handler_accepts() {
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if EDIT_INDEXER_BLOCKS.contains(&active_radarr_block) {
|
||||
assert!(EditIndexerHandler::accepts(&active_radarr_block));
|
||||
assert!(EditIndexerHandler::accepts(active_radarr_block));
|
||||
} else {
|
||||
assert!(!EditIndexerHandler::accepts(&active_radarr_block));
|
||||
assert!(!EditIndexerHandler::accepts(active_radarr_block));
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1613,10 +1603,10 @@ mod tests {
|
||||
app.is_loading = true;
|
||||
|
||||
let handler = EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerPrompt,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -1628,10 +1618,10 @@ mod tests {
|
||||
app.is_loading = false;
|
||||
|
||||
let handler = EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerPrompt,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -1644,10 +1634,10 @@ mod tests {
|
||||
app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default());
|
||||
|
||||
let handler = EditIndexerHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditIndexerPrompt,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
|
||||
@@ -13,22 +13,22 @@ use crate::{handle_text_box_keys, handle_text_box_left_right_keys};
|
||||
mod edit_indexer_settings_handler_tests;
|
||||
|
||||
pub(super) struct IndexerSettingsHandler<'a, 'b> {
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_radarr_block: &'a ActiveRadarrBlock,
|
||||
_context: &'a Option<ActiveRadarrBlock>,
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexerSettingsHandler<'a, 'b> {
|
||||
fn accepts(active_block: &'a ActiveRadarrBlock) -> bool {
|
||||
INDEXER_SETTINGS_BLOCKS.contains(active_block)
|
||||
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
||||
INDEXER_SETTINGS_BLOCKS.contains(&active_block)
|
||||
}
|
||||
|
||||
fn with(
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_block: &'a ActiveRadarrBlock,
|
||||
_context: &'a Option<ActiveRadarrBlock>,
|
||||
active_block: ActiveRadarrBlock,
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
) -> IndexerSettingsHandler<'a, 'b> {
|
||||
IndexerSettingsHandler {
|
||||
key,
|
||||
@@ -38,7 +38,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexerSettingsHandl
|
||||
}
|
||||
}
|
||||
|
||||
fn get_key(&self) -> &Key {
|
||||
fn get_key(&self) -> Key {
|
||||
self.key
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexerSettingsHandl
|
||||
}
|
||||
|
||||
fn handle_home(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput {
|
||||
self
|
||||
.app
|
||||
.data
|
||||
@@ -119,7 +119,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexerSettingsHandl
|
||||
}
|
||||
|
||||
fn handle_end(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput {
|
||||
self
|
||||
.app
|
||||
.data
|
||||
@@ -138,7 +138,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexerSettingsHandl
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt => {
|
||||
if self.app.data.radarr_data.selected_block.get_active_block()
|
||||
== &ActiveRadarrBlock::IndexerSettingsConfirmPrompt
|
||||
== ActiveRadarrBlock::IndexerSettingsConfirmPrompt
|
||||
{
|
||||
handle_prompt_toggle(self.app, self.key);
|
||||
} else {
|
||||
@@ -187,7 +187,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexerSettingsHandl
|
||||
| ActiveRadarrBlock::IndexerSettingsRssSyncIntervalInput => {
|
||||
self.app.push_navigation_stack(
|
||||
(
|
||||
*self.app.data.radarr_data.selected_block.get_active_block(),
|
||||
self.app.data.radarr_data.selected_block.get_active_block(),
|
||||
None,
|
||||
)
|
||||
.into(),
|
||||
@@ -258,8 +258,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexerSettingsHandl
|
||||
}
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt => {
|
||||
if self.app.data.radarr_data.selected_block.get_active_block()
|
||||
== &ActiveRadarrBlock::IndexerSettingsConfirmPrompt
|
||||
&& *self.key == DEFAULT_KEYBINDINGS.confirm.key
|
||||
== ActiveRadarrBlock::IndexerSettingsConfirmPrompt
|
||||
&& self.key == DEFAULT_KEYBINDINGS.confirm.key
|
||||
{
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action =
|
||||
|
||||
@@ -27,7 +27,7 @@ mod tests {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data.indexer_settings = Some(IndexerSettings::default());
|
||||
|
||||
IndexerSettingsHandler::with(&$key, &mut app, &$block, &None).handle();
|
||||
IndexerSettingsHandler::with($key, &mut app, $block, None).handle();
|
||||
|
||||
if $key == Key::Up {
|
||||
assert_eq!(
|
||||
@@ -64,7 +64,7 @@ mod tests {
|
||||
0
|
||||
);
|
||||
|
||||
IndexerSettingsHandler::with(&Key::Up, &mut app, &$block, &None).handle();
|
||||
IndexerSettingsHandler::with(Key::Up, &mut app, $block, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app
|
||||
@@ -77,7 +77,7 @@ mod tests {
|
||||
1
|
||||
);
|
||||
|
||||
IndexerSettingsHandler::with(&$key, &mut app, &$block, &None).handle();
|
||||
IndexerSettingsHandler::with($key, &mut app, $block, None).handle();
|
||||
assert_eq!(
|
||||
app
|
||||
.data
|
||||
@@ -102,22 +102,22 @@ mod tests {
|
||||
app.data.radarr_data.selected_block.next();
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
if key == Key::Up {
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::IndexerSettingsMinimumAgeInput
|
||||
ActiveRadarrBlock::IndexerSettingsMinimumAgeInput
|
||||
);
|
||||
} else {
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::IndexerSettingsMaximumSizeInput
|
||||
ActiveRadarrBlock::IndexerSettingsMaximumSizeInput
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -134,16 +134,16 @@ mod tests {
|
||||
app.data.radarr_data.selected_block.next();
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::IndexerSettingsRetentionInput
|
||||
ActiveRadarrBlock::IndexerSettingsRetentionInput
|
||||
);
|
||||
}
|
||||
|
||||
@@ -218,10 +218,10 @@ mod tests {
|
||||
});
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -239,10 +239,10 @@ mod tests {
|
||||
);
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -280,20 +280,20 @@ mod tests {
|
||||
app.data.radarr_data.selected_block.index = INDEXER_SETTINGS_SELECTION_BLOCKS.len() - 1;
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -334,33 +334,33 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&left_block
|
||||
left_block
|
||||
);
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&right_block
|
||||
right_block
|
||||
);
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&left_block
|
||||
left_block
|
||||
);
|
||||
}
|
||||
|
||||
@@ -373,10 +373,10 @@ mod tests {
|
||||
});
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -394,10 +394,10 @@ mod tests {
|
||||
);
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -447,14 +447,14 @@ mod tests {
|
||||
app.data.radarr_data.indexer_settings = Some(IndexerSettings::default());
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
assert!(!app.should_refresh);
|
||||
assert_eq!(app.data.radarr_data.indexer_settings, None);
|
||||
@@ -476,14 +476,14 @@ mod tests {
|
||||
app.data.radarr_data.prompt_confirm = true;
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
Some(RadarrEvent::EditAllIndexerSettings(None))
|
||||
@@ -502,16 +502,16 @@ mod tests {
|
||||
app.data.radarr_data.prompt_confirm = true;
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
);
|
||||
assert!(!app.should_refresh);
|
||||
}
|
||||
@@ -534,14 +534,14 @@ mod tests {
|
||||
app.data.radarr_data.selected_block.set_index(index);
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &selected_block.into());
|
||||
assert_eq!(app.get_current_route(), selected_block.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -557,16 +557,16 @@ mod tests {
|
||||
app.data.radarr_data.selected_block.set_index(index);
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -580,16 +580,16 @@ mod tests {
|
||||
app.data.radarr_data.selected_block.set_index(7);
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput.into()
|
||||
ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput.into()
|
||||
);
|
||||
assert!(app.should_ignore_quit_key);
|
||||
}
|
||||
@@ -604,16 +604,16 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::AllIndexerSettingsPrompt.into());
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
);
|
||||
assert!(
|
||||
app
|
||||
@@ -626,16 +626,16 @@ mod tests {
|
||||
);
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
);
|
||||
assert!(
|
||||
!app
|
||||
@@ -658,16 +658,16 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::AllIndexerSettingsPrompt.into());
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
);
|
||||
assert!(
|
||||
app
|
||||
@@ -680,16 +680,16 @@ mod tests {
|
||||
);
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
);
|
||||
assert!(
|
||||
!app
|
||||
@@ -716,10 +716,10 @@ mod tests {
|
||||
);
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -735,7 +735,7 @@ mod tests {
|
||||
.is_empty());
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -755,11 +755,11 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::AllIndexerSettingsPrompt.into());
|
||||
app.push_navigation_stack(active_radarr_block.into());
|
||||
|
||||
IndexerSettingsHandler::with(&SUBMIT_KEY, &mut app, &active_radarr_block, &None).handle();
|
||||
IndexerSettingsHandler::with(SUBMIT_KEY, &mut app, active_radarr_block, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -783,14 +783,14 @@ mod tests {
|
||||
app.data.radarr_data.indexer_settings = Some(IndexerSettings::default());
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
assert_eq!(app.data.radarr_data.indexer_settings, None);
|
||||
}
|
||||
@@ -806,14 +806,14 @@ mod tests {
|
||||
app.should_ignore_quit_key = true;
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput,
|
||||
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_eq!(
|
||||
app.data.radarr_data.indexer_settings,
|
||||
@@ -838,9 +838,9 @@ mod tests {
|
||||
app.push_navigation_stack(active_radarr_block.into());
|
||||
app.data.radarr_data.indexer_settings = Some(IndexerSettings::default());
|
||||
|
||||
IndexerSettingsHandler::with(&ESC_KEY, &mut app, &active_radarr_block, &None).handle();
|
||||
IndexerSettingsHandler::with(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_eq!(
|
||||
app.data.radarr_data.indexer_settings,
|
||||
Some(IndexerSettings::default())
|
||||
@@ -870,10 +870,10 @@ mod tests {
|
||||
});
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
DEFAULT_KEYBINDINGS.backspace.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -896,10 +896,10 @@ mod tests {
|
||||
app.data.radarr_data.indexer_settings = Some(IndexerSettings::default());
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&Key::Char('h'),
|
||||
Key::Char('h'),
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -931,14 +931,14 @@ mod tests {
|
||||
app.data.radarr_data.indexer_settings = Some(IndexerSettings::default());
|
||||
|
||||
IndexerSettingsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.confirm.key,
|
||||
DEFAULT_KEYBINDINGS.confirm.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
Some(RadarrEvent::EditAllIndexerSettings(None))
|
||||
@@ -952,9 +952,9 @@ mod tests {
|
||||
fn test_indexer_settings_handler_accepts() {
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if INDEXER_SETTINGS_BLOCKS.contains(&active_radarr_block) {
|
||||
assert!(IndexerSettingsHandler::accepts(&active_radarr_block));
|
||||
assert!(IndexerSettingsHandler::accepts(active_radarr_block));
|
||||
} else {
|
||||
assert!(!IndexerSettingsHandler::accepts(&active_radarr_block));
|
||||
assert!(!IndexerSettingsHandler::accepts(active_radarr_block));
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -965,10 +965,10 @@ mod tests {
|
||||
app.is_loading = true;
|
||||
|
||||
let handler = IndexerSettingsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -980,10 +980,10 @@ mod tests {
|
||||
app.is_loading = false;
|
||||
|
||||
let handler = IndexerSettingsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -996,10 +996,10 @@ mod tests {
|
||||
app.data.radarr_data.indexer_settings = Some(IndexerSettings::default());
|
||||
|
||||
let handler = IndexerSettingsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
|
||||
@@ -47,14 +47,14 @@ mod tests {
|
||||
.indexers
|
||||
.set_items(simple_stateful_iterable_vec!(Indexer, String, protocol));
|
||||
|
||||
IndexersHandler::with(&key, &mut app, &ActiveRadarrBlock::Indexers, &None).handle();
|
||||
IndexersHandler::with(key, &mut app, ActiveRadarrBlock::Indexers, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.indexers.current_selection().protocol,
|
||||
"Test 1"
|
||||
);
|
||||
|
||||
IndexersHandler::with(&key, &mut app, &ActiveRadarrBlock::Indexers, &None).handle();
|
||||
IndexersHandler::with(key, &mut app, ActiveRadarrBlock::Indexers, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.indexers.current_selection().protocol,
|
||||
@@ -89,10 +89,10 @@ mod tests {
|
||||
.set_items(extended_stateful_iterable_vec!(Indexer, String, protocol));
|
||||
|
||||
IndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Indexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::Indexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -102,10 +102,10 @@ mod tests {
|
||||
);
|
||||
|
||||
IndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Indexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::Indexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -132,11 +132,11 @@ mod tests {
|
||||
.indexers
|
||||
.set_items(vec![Indexer::default()]);
|
||||
|
||||
IndexersHandler::with(&DELETE_KEY, &mut app, &ActiveRadarrBlock::Indexers, &None).handle();
|
||||
IndexersHandler::with(DELETE_KEY, &mut app, ActiveRadarrBlock::Indexers, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::DeleteIndexerPrompt.into()
|
||||
ActiveRadarrBlock::DeleteIndexerPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -151,9 +151,9 @@ mod tests {
|
||||
.indexers
|
||||
.set_items(vec![Indexer::default()]);
|
||||
|
||||
IndexersHandler::with(&DELETE_KEY, &mut app, &ActiveRadarrBlock::Indexers, &None).handle();
|
||||
IndexersHandler::with(DELETE_KEY, &mut app, ActiveRadarrBlock::Indexers, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,20 +170,20 @@ mod tests {
|
||||
app.data.radarr_data.main_tabs.set_index(5);
|
||||
|
||||
IndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Indexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::Indexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.main_tabs.get_active_route(),
|
||||
&ActiveRadarrBlock::RootFolders.into()
|
||||
ActiveRadarrBlock::RootFolders.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::RootFolders.into()
|
||||
ActiveRadarrBlock::RootFolders.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -194,18 +194,18 @@ mod tests {
|
||||
app.data.radarr_data.main_tabs.set_index(5);
|
||||
|
||||
IndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Indexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::Indexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.main_tabs.get_active_route(),
|
||||
&ActiveRadarrBlock::System.into()
|
||||
ActiveRadarrBlock::System.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::System.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::System.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -214,23 +214,11 @@ mod tests {
|
||||
) {
|
||||
let mut app = App::default();
|
||||
|
||||
IndexersHandler::with(
|
||||
&key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteIndexerPrompt,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
IndexersHandler::with(key, &mut app, ActiveRadarrBlock::DeleteIndexerPrompt, None).handle();
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
IndexersHandler::with(
|
||||
&key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteIndexerPrompt,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
IndexersHandler::with(key, &mut app, ActiveRadarrBlock::DeleteIndexerPrompt, None).handle();
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
@@ -306,11 +294,11 @@ mod tests {
|
||||
radarr_data.indexers.set_items(vec![indexer]);
|
||||
app.data.radarr_data = radarr_data;
|
||||
|
||||
IndexersHandler::with(&SUBMIT_KEY, &mut app, &ActiveRadarrBlock::Indexers, &None).handle();
|
||||
IndexersHandler::with(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Indexers, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.data.radarr_data.edit_indexer_modal,
|
||||
@@ -344,9 +332,9 @@ mod tests {
|
||||
.indexers
|
||||
.set_items(vec![Indexer::default()]);
|
||||
|
||||
IndexersHandler::with(&SUBMIT_KEY, &mut app, &ActiveRadarrBlock::Indexers, &None).handle();
|
||||
IndexersHandler::with(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Indexers, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.data.radarr_data.edit_indexer_modal, None);
|
||||
}
|
||||
|
||||
@@ -363,10 +351,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::DeleteIndexerPrompt.into());
|
||||
|
||||
IndexersHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteIndexerPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -375,7 +363,7 @@ mod tests {
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
Some(RadarrEvent::DeleteIndexer(None))
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -390,16 +378,16 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::DeleteIndexerPrompt.into());
|
||||
|
||||
IndexersHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteIndexerPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,14 +407,14 @@ mod tests {
|
||||
app.data.radarr_data.prompt_confirm = true;
|
||||
|
||||
IndexersHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteIndexerPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
|
||||
@@ -438,9 +426,9 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::TestIndexer.into());
|
||||
|
||||
IndexersHandler::with(&ESC_KEY, &mut app, &ActiveRadarrBlock::TestIndexer, &None).handle();
|
||||
IndexersHandler::with(ESC_KEY, &mut app, ActiveRadarrBlock::TestIndexer, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.data.radarr_data.indexer_test_error, None);
|
||||
}
|
||||
|
||||
@@ -452,9 +440,9 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
|
||||
IndexersHandler::with(&ESC_KEY, &mut app, &ActiveRadarrBlock::Indexers, &None).handle();
|
||||
IndexersHandler::with(ESC_KEY, &mut app, ActiveRadarrBlock::Indexers, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert!(app.error.text.is_empty());
|
||||
}
|
||||
}
|
||||
@@ -479,16 +467,16 @@ mod tests {
|
||||
.set_items(vec![Indexer::default()]);
|
||||
|
||||
IndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.add.key,
|
||||
DEFAULT_KEYBINDINGS.add.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Indexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::Indexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddIndexer.into()
|
||||
ActiveRadarrBlock::AddIndexer.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -504,14 +492,14 @@ mod tests {
|
||||
.set_items(vec![Indexer::default()]);
|
||||
|
||||
IndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.add.key,
|
||||
DEFAULT_KEYBINDINGS.add.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Indexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::Indexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -525,14 +513,14 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
|
||||
IndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.refresh.key,
|
||||
DEFAULT_KEYBINDINGS.refresh.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Indexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::Indexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert!(app.should_refresh);
|
||||
}
|
||||
|
||||
@@ -548,14 +536,14 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Indexers.into());
|
||||
|
||||
IndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.refresh.key,
|
||||
DEFAULT_KEYBINDINGS.refresh.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Indexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::Indexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert!(!app.should_refresh);
|
||||
}
|
||||
|
||||
@@ -569,16 +557,16 @@ mod tests {
|
||||
.set_items(vec![Indexer::default()]);
|
||||
|
||||
IndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.settings.key,
|
||||
DEFAULT_KEYBINDINGS.settings.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Indexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::Indexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.blocks,
|
||||
@@ -598,14 +586,14 @@ mod tests {
|
||||
.set_items(vec![Indexer::default()]);
|
||||
|
||||
IndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.settings.key,
|
||||
DEFAULT_KEYBINDINGS.settings.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Indexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::Indexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -618,16 +606,16 @@ mod tests {
|
||||
.set_items(vec![Indexer::default()]);
|
||||
|
||||
IndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.test.key,
|
||||
DEFAULT_KEYBINDINGS.test.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Indexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::Indexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::TestIndexer.into()
|
||||
ActiveRadarrBlock::TestIndexer.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -643,14 +631,14 @@ mod tests {
|
||||
.set_items(vec![Indexer::default()]);
|
||||
|
||||
IndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.test.key,
|
||||
DEFAULT_KEYBINDINGS.test.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Indexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::Indexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -663,16 +651,16 @@ mod tests {
|
||||
.set_items(vec![Indexer::default()]);
|
||||
|
||||
IndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.test_all.key,
|
||||
DEFAULT_KEYBINDINGS.test_all.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Indexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::Indexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::TestAllIndexers.into()
|
||||
ActiveRadarrBlock::TestAllIndexers.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -688,14 +676,14 @@ mod tests {
|
||||
.set_items(vec![Indexer::default()]);
|
||||
|
||||
IndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.test_all.key,
|
||||
DEFAULT_KEYBINDINGS.test_all.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Indexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::Indexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -710,10 +698,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::DeleteIndexerPrompt.into());
|
||||
|
||||
IndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.confirm.key,
|
||||
DEFAULT_KEYBINDINGS.confirm.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteIndexerPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteIndexerPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -722,7 +710,7 @@ mod tests {
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
Some(RadarrEvent::DeleteIndexer(None))
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -791,9 +779,9 @@ mod tests {
|
||||
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if indexers_blocks.contains(&active_radarr_block) {
|
||||
assert!(IndexersHandler::accepts(&active_radarr_block));
|
||||
assert!(IndexersHandler::accepts(active_radarr_block));
|
||||
} else {
|
||||
assert!(!IndexersHandler::accepts(&active_radarr_block));
|
||||
assert!(!IndexersHandler::accepts(active_radarr_block));
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -804,10 +792,10 @@ mod tests {
|
||||
app.is_loading = true;
|
||||
|
||||
let handler = IndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Indexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::Indexers,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -819,10 +807,10 @@ mod tests {
|
||||
app.is_loading = false;
|
||||
|
||||
let handler = IndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Indexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::Indexers,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -839,10 +827,10 @@ mod tests {
|
||||
.set_items(vec![Indexer::default()]);
|
||||
|
||||
let handler = IndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Indexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::Indexers,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
|
||||
@@ -23,10 +23,10 @@ mod test_all_indexers_handler;
|
||||
mod indexers_handler_tests;
|
||||
|
||||
pub(super) struct IndexersHandler<'a, 'b> {
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_radarr_block: &'a ActiveRadarrBlock,
|
||||
context: &'a Option<ActiveRadarrBlock>,
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexersHandler<'a, 'b> {
|
||||
@@ -48,18 +48,18 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexersHandler<'a,
|
||||
}
|
||||
}
|
||||
|
||||
fn accepts(active_block: &'a ActiveRadarrBlock) -> bool {
|
||||
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
||||
EditIndexerHandler::accepts(active_block)
|
||||
|| IndexerSettingsHandler::accepts(active_block)
|
||||
|| TestAllIndexersHandler::accepts(active_block)
|
||||
|| INDEXERS_BLOCKS.contains(active_block)
|
||||
|| INDEXERS_BLOCKS.contains(&active_block)
|
||||
}
|
||||
|
||||
fn with(
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_block: &'a ActiveRadarrBlock,
|
||||
context: &'a Option<ActiveRadarrBlock>,
|
||||
active_block: ActiveRadarrBlock,
|
||||
context: Option<ActiveRadarrBlock>,
|
||||
) -> IndexersHandler<'a, 'b> {
|
||||
IndexersHandler {
|
||||
key,
|
||||
@@ -69,7 +69,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexersHandler<'a,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_key(&self) -> &Key {
|
||||
fn get_key(&self) -> Key {
|
||||
self.key
|
||||
}
|
||||
|
||||
@@ -78,31 +78,31 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexersHandler<'a,
|
||||
}
|
||||
|
||||
fn handle_scroll_up(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::Indexers {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::Indexers {
|
||||
self.app.data.radarr_data.indexers.scroll_up();
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_scroll_down(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::Indexers {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::Indexers {
|
||||
self.app.data.radarr_data.indexers.scroll_down();
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_home(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::Indexers {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::Indexers {
|
||||
self.app.data.radarr_data.indexers.scroll_to_top();
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_end(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::Indexers {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::Indexers {
|
||||
self.app.data.radarr_data.indexers.scroll_to_bottom();
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_delete(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::Indexers {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::Indexers {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::DeleteIndexerPrompt.into());
|
||||
@@ -169,25 +169,25 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexersHandler<'a,
|
||||
let key = self.key;
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::Indexers => match self.key {
|
||||
_ if *key == DEFAULT_KEYBINDINGS.add.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.add.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::AddIndexer.into());
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||
self.app.should_refresh = true;
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.test.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.test.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::TestIndexer.into());
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.test_all.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.test_all.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::TestAllIndexers.into());
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.settings.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.settings.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::AllIndexerSettingsPrompt.into());
|
||||
@@ -197,7 +197,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexersHandler<'a,
|
||||
_ => (),
|
||||
},
|
||||
ActiveRadarrBlock::DeleteIndexerPrompt => {
|
||||
if *key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
if key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action = Some(RadarrEvent::DeleteIndexer(None));
|
||||
|
||||
|
||||
@@ -9,22 +9,22 @@ use crate::models::Scrollable;
|
||||
mod test_all_indexers_handler_tests;
|
||||
|
||||
pub(super) struct TestAllIndexersHandler<'a, 'b> {
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_radarr_block: &'a ActiveRadarrBlock,
|
||||
_context: &'a Option<ActiveRadarrBlock>,
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for TestAllIndexersHandler<'a, 'b> {
|
||||
fn accepts(active_block: &'a ActiveRadarrBlock) -> bool {
|
||||
active_block == &ActiveRadarrBlock::TestAllIndexers
|
||||
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
||||
active_block == ActiveRadarrBlock::TestAllIndexers
|
||||
}
|
||||
|
||||
fn with(
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_block: &'a ActiveRadarrBlock,
|
||||
_context: &'a Option<ActiveRadarrBlock>,
|
||||
active_block: ActiveRadarrBlock,
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
) -> TestAllIndexersHandler<'a, 'b> {
|
||||
TestAllIndexersHandler {
|
||||
key,
|
||||
@@ -34,7 +34,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for TestAllIndexersHandl
|
||||
}
|
||||
}
|
||||
|
||||
fn get_key(&self) -> &Key {
|
||||
fn get_key(&self) -> Key {
|
||||
self.key
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for TestAllIndexersHandl
|
||||
}
|
||||
|
||||
fn handle_scroll_up(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::TestAllIndexers {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::TestAllIndexers {
|
||||
self
|
||||
.app
|
||||
.data
|
||||
@@ -62,7 +62,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for TestAllIndexersHandl
|
||||
}
|
||||
|
||||
fn handle_scroll_down(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::TestAllIndexers {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::TestAllIndexers {
|
||||
self
|
||||
.app
|
||||
.data
|
||||
@@ -75,7 +75,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for TestAllIndexersHandl
|
||||
}
|
||||
|
||||
fn handle_home(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::TestAllIndexers {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::TestAllIndexers {
|
||||
self
|
||||
.app
|
||||
.data
|
||||
@@ -88,7 +88,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for TestAllIndexersHandl
|
||||
}
|
||||
|
||||
fn handle_end(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::TestAllIndexers {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::TestAllIndexers {
|
||||
self
|
||||
.app
|
||||
.data
|
||||
@@ -107,7 +107,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for TestAllIndexersHandl
|
||||
fn handle_submit(&mut self) {}
|
||||
|
||||
fn handle_esc(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::TestAllIndexers {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::TestAllIndexers {
|
||||
self.app.pop_navigation_stack();
|
||||
self.app.data.radarr_data.indexer_test_all_results = None;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ mod tests {
|
||||
));
|
||||
app.data.radarr_data.indexer_test_all_results = Some(indexer_test_results);
|
||||
|
||||
TestAllIndexersHandler::with(&key, &mut app, &ActiveRadarrBlock::TestAllIndexers, &None)
|
||||
TestAllIndexersHandler::with(key, &mut app, ActiveRadarrBlock::TestAllIndexers, None)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(
|
||||
@@ -48,7 +48,7 @@ mod tests {
|
||||
"Test 2"
|
||||
);
|
||||
|
||||
TestAllIndexersHandler::with(&key, &mut app, &ActiveRadarrBlock::TestAllIndexers, &None)
|
||||
TestAllIndexersHandler::with(key, &mut app, ActiveRadarrBlock::TestAllIndexers, None)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(
|
||||
@@ -78,7 +78,7 @@ mod tests {
|
||||
));
|
||||
app.data.radarr_data.indexer_test_all_results = Some(indexer_test_results);
|
||||
|
||||
TestAllIndexersHandler::with(&key, &mut app, &ActiveRadarrBlock::TestAllIndexers, &None)
|
||||
TestAllIndexersHandler::with(key, &mut app, ActiveRadarrBlock::TestAllIndexers, None)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(
|
||||
@@ -93,7 +93,7 @@ mod tests {
|
||||
"Test 1"
|
||||
);
|
||||
|
||||
TestAllIndexersHandler::with(&key, &mut app, &ActiveRadarrBlock::TestAllIndexers, &None)
|
||||
TestAllIndexersHandler::with(key, &mut app, ActiveRadarrBlock::TestAllIndexers, None)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(
|
||||
@@ -130,10 +130,10 @@ mod tests {
|
||||
app.data.radarr_data.indexer_test_all_results = Some(indexer_test_results);
|
||||
|
||||
TestAllIndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::TestAllIndexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::TestAllIndexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -150,10 +150,10 @@ mod tests {
|
||||
);
|
||||
|
||||
TestAllIndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::TestAllIndexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::TestAllIndexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -183,10 +183,10 @@ mod tests {
|
||||
app.data.radarr_data.indexer_test_all_results = Some(indexer_test_results);
|
||||
|
||||
TestAllIndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::TestAllIndexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::TestAllIndexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -203,10 +203,10 @@ mod tests {
|
||||
);
|
||||
|
||||
TestAllIndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::TestAllIndexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::TestAllIndexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -239,14 +239,14 @@ mod tests {
|
||||
app.data.radarr_data.indexer_test_all_results = Some(StatefulTable::default());
|
||||
|
||||
TestAllIndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::TestAllIndexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::TestAllIndexers,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
assert!(app.data.radarr_data.indexer_test_all_results.is_none());
|
||||
}
|
||||
@@ -256,9 +256,9 @@ mod tests {
|
||||
fn test_test_all_indexers_handler_accepts() {
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if active_radarr_block == ActiveRadarrBlock::TestAllIndexers {
|
||||
assert!(TestAllIndexersHandler::accepts(&active_radarr_block));
|
||||
assert!(TestAllIndexersHandler::accepts(active_radarr_block));
|
||||
} else {
|
||||
assert!(!TestAllIndexersHandler::accepts(&active_radarr_block));
|
||||
assert!(!TestAllIndexersHandler::accepts(active_radarr_block));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -269,10 +269,10 @@ mod tests {
|
||||
app.is_loading = true;
|
||||
|
||||
let handler = TestAllIndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::TestAllIndexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::TestAllIndexers,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -284,10 +284,10 @@ mod tests {
|
||||
app.is_loading = false;
|
||||
|
||||
let handler = TestAllIndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::TestAllIndexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::TestAllIndexers,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -300,10 +300,10 @@ mod tests {
|
||||
app.data.radarr_data.indexer_test_all_results = Some(StatefulTable::default());
|
||||
|
||||
let handler = TestAllIndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::TestAllIndexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::TestAllIndexers,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -318,10 +318,10 @@ mod tests {
|
||||
app.data.radarr_data.indexer_test_all_results = Some(indexer_test_results);
|
||||
|
||||
let handler = TestAllIndexersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::TestAllIndexers,
|
||||
&None,
|
||||
ActiveRadarrBlock::TestAllIndexers,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
|
||||
@@ -12,22 +12,22 @@ use crate::{handle_text_box_keys, handle_text_box_left_right_keys, App, Key};
|
||||
mod add_movie_handler_tests;
|
||||
|
||||
pub(super) struct AddMovieHandler<'a, 'b> {
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_radarr_block: &'a ActiveRadarrBlock,
|
||||
context: &'a Option<ActiveRadarrBlock>,
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a, 'b> {
|
||||
fn accepts(active_block: &'a ActiveRadarrBlock) -> bool {
|
||||
ADD_MOVIE_BLOCKS.contains(active_block)
|
||||
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
||||
ADD_MOVIE_BLOCKS.contains(&active_block)
|
||||
}
|
||||
|
||||
fn with(
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_block: &'a ActiveRadarrBlock,
|
||||
context: &'a Option<ActiveRadarrBlock>,
|
||||
active_block: ActiveRadarrBlock,
|
||||
context: Option<ActiveRadarrBlock>,
|
||||
) -> AddMovieHandler<'a, 'b> {
|
||||
AddMovieHandler {
|
||||
key,
|
||||
@@ -37,7 +37,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_key(&self) -> &Key {
|
||||
fn get_key(&self) -> Key {
|
||||
self.key
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
|
||||
|
||||
fn handle_submit(&mut self) {
|
||||
match self.active_radarr_block {
|
||||
_ if *self.active_radarr_block == ActiveRadarrBlock::AddMovieSearchInput
|
||||
_ if self.active_radarr_block == ActiveRadarrBlock::AddMovieSearchInput
|
||||
&& !self
|
||||
.app
|
||||
.data
|
||||
@@ -329,7 +329,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
|
||||
.push_navigation_stack(ActiveRadarrBlock::AddMovieSearchResults.into());
|
||||
self.app.should_ignore_quit_key = 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() =>
|
||||
{
|
||||
let tmdb_id = self
|
||||
@@ -377,16 +377,16 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
|
||||
| ActiveRadarrBlock::AddMovieSelectQualityProfile
|
||||
| ActiveRadarrBlock::AddMovieSelectRootFolder => self.app.push_navigation_stack(
|
||||
(
|
||||
*self.app.data.radarr_data.selected_block.get_active_block(),
|
||||
*self.context,
|
||||
self.app.data.radarr_data.selected_block.get_active_block(),
|
||||
self.context,
|
||||
)
|
||||
.into(),
|
||||
),
|
||||
ActiveRadarrBlock::AddMovieTagsInput => {
|
||||
self.app.push_navigation_stack(
|
||||
(
|
||||
*self.app.data.radarr_data.selected_block.get_active_block(),
|
||||
*self.context,
|
||||
self.app.data.radarr_data.selected_block.get_active_block(),
|
||||
self.context,
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
@@ -463,8 +463,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
|
||||
}
|
||||
ActiveRadarrBlock::AddMoviePrompt => {
|
||||
if self.app.data.radarr_data.selected_block.get_active_block()
|
||||
== &ActiveRadarrBlock::AddMovieConfirmPrompt
|
||||
&& *key == DEFAULT_KEYBINDINGS.confirm.key
|
||||
== ActiveRadarrBlock::AddMovieConfirmPrompt
|
||||
&& key == DEFAULT_KEYBINDINGS.confirm.key
|
||||
{
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action = Some(RadarrEvent::AddMovie(None));
|
||||
|
||||
@@ -39,10 +39,10 @@ mod tests {
|
||||
app.data.radarr_data.add_searched_movies = Some(add_searched_movies);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchResults,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchResults,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -60,10 +60,10 @@ mod tests {
|
||||
);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchResults,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchResults,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -95,10 +95,10 @@ mod tests {
|
||||
app.data.radarr_data.add_searched_movies = Some(add_searched_movies);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchResults,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchResults,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -116,10 +116,10 @@ mod tests {
|
||||
);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchResults,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchResults,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -156,10 +156,10 @@ mod tests {
|
||||
if key == Key::Up {
|
||||
for i in (0..monitor_vec.len()).rev() {
|
||||
AddMovieHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSelectMonitor,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSelectMonitor,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -178,10 +178,10 @@ mod tests {
|
||||
} else {
|
||||
for i in 0..monitor_vec.len() {
|
||||
AddMovieHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSelectMonitor,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSelectMonitor,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -219,10 +219,10 @@ mod tests {
|
||||
if key == Key::Up {
|
||||
for i in (0..minimum_availability_vec.len()).rev() {
|
||||
AddMovieHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSelectMinimumAvailability,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSelectMinimumAvailability,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -241,10 +241,10 @@ mod tests {
|
||||
} else {
|
||||
for i in 0..minimum_availability_vec.len() {
|
||||
AddMovieHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSelectMinimumAvailability,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSelectMinimumAvailability,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -279,10 +279,10 @@ mod tests {
|
||||
.set_items(vec!["Test 1".to_owned(), "Test 2".to_owned()]);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSelectQualityProfile,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSelectQualityProfile,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -299,10 +299,10 @@ mod tests {
|
||||
);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSelectQualityProfile,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSelectQualityProfile,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -335,10 +335,10 @@ mod tests {
|
||||
.set_items(simple_stateful_iterable_vec!(RootFolder, String, path));
|
||||
|
||||
AddMovieHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSelectRootFolder,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSelectRootFolder,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -356,10 +356,10 @@ mod tests {
|
||||
);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSelectRootFolder,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSelectRootFolder,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -383,17 +383,17 @@ mod tests {
|
||||
app.data.radarr_data.selected_block = BlockSelectionState::new(&ADD_MOVIE_SELECTION_BLOCKS);
|
||||
app.data.radarr_data.selected_block.next();
|
||||
|
||||
AddMovieHandler::with(&key, &mut app, &ActiveRadarrBlock::AddMoviePrompt, &None).handle();
|
||||
AddMovieHandler::with(key, &mut app, ActiveRadarrBlock::AddMoviePrompt, None).handle();
|
||||
|
||||
if key == Key::Up {
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::AddMovieSelectRootFolder
|
||||
ActiveRadarrBlock::AddMovieSelectRootFolder
|
||||
);
|
||||
} else {
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::AddMovieSelectMinimumAvailability
|
||||
ActiveRadarrBlock::AddMovieSelectMinimumAvailability
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -405,11 +405,11 @@ mod tests {
|
||||
app.data.radarr_data.selected_block = BlockSelectionState::new(&ADD_MOVIE_SELECTION_BLOCKS);
|
||||
app.data.radarr_data.selected_block.next();
|
||||
|
||||
AddMovieHandler::with(&key, &mut app, &ActiveRadarrBlock::AddMoviePrompt, &None).handle();
|
||||
AddMovieHandler::with(key, &mut app, ActiveRadarrBlock::AddMoviePrompt, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::AddMovieSelectMonitor
|
||||
ActiveRadarrBlock::AddMovieSelectMonitor
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -436,10 +436,10 @@ mod tests {
|
||||
app.data.radarr_data.add_searched_movies = Some(add_searched_movies);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchResults,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchResults,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -457,10 +457,10 @@ mod tests {
|
||||
);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchResults,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchResults,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -490,10 +490,10 @@ mod tests {
|
||||
app.data.radarr_data.add_searched_movies = Some(add_searched_movies);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchResults,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchResults,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -511,10 +511,10 @@ mod tests {
|
||||
);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchResults,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchResults,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -547,10 +547,10 @@ mod tests {
|
||||
.set_items(monitor_vec.clone());
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSelectMonitor,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSelectMonitor,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -567,10 +567,10 @@ mod tests {
|
||||
);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSelectMonitor,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSelectMonitor,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -602,10 +602,10 @@ mod tests {
|
||||
.set_items(minimum_availability_vec.clone());
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSelectMinimumAvailability,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSelectMinimumAvailability,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -622,10 +622,10 @@ mod tests {
|
||||
);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSelectMinimumAvailability,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSelectMinimumAvailability,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -660,10 +660,10 @@ mod tests {
|
||||
]);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSelectQualityProfile,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSelectQualityProfile,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -680,10 +680,10 @@ mod tests {
|
||||
);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSelectQualityProfile,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSelectQualityProfile,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -714,10 +714,10 @@ mod tests {
|
||||
.set_items(extended_stateful_iterable_vec!(RootFolder, String, path));
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSelectRootFolder,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSelectRootFolder,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -735,10 +735,10 @@ mod tests {
|
||||
);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSelectRootFolder,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSelectRootFolder,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -762,10 +762,10 @@ mod tests {
|
||||
app.data.radarr_data.add_movie_search = Some("Test".into());
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -782,10 +782,10 @@ mod tests {
|
||||
);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -811,10 +811,10 @@ mod tests {
|
||||
});
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -832,10 +832,10 @@ mod tests {
|
||||
);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -866,11 +866,11 @@ mod tests {
|
||||
fn test_left_right_prompt_toggle(#[values(Key::Left, Key::Right)] key: Key) {
|
||||
let mut app = App::default();
|
||||
|
||||
AddMovieHandler::with(&key, &mut app, &ActiveRadarrBlock::AddMoviePrompt, &None).handle();
|
||||
AddMovieHandler::with(key, &mut app, ActiveRadarrBlock::AddMoviePrompt, None).handle();
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
AddMovieHandler::with(&key, &mut app, &ActiveRadarrBlock::AddMoviePrompt, &None).handle();
|
||||
AddMovieHandler::with(key, &mut app, ActiveRadarrBlock::AddMoviePrompt, None).handle();
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
@@ -881,10 +881,10 @@ mod tests {
|
||||
app.data.radarr_data.add_movie_search = Some("Test".into());
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -901,10 +901,10 @@ mod tests {
|
||||
);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -930,10 +930,10 @@ mod tests {
|
||||
});
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -951,10 +951,10 @@ mod tests {
|
||||
);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -996,17 +996,17 @@ mod tests {
|
||||
app.data.radarr_data.add_movie_search = Some("test".into());
|
||||
|
||||
AddMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddMovieSearchResults.into()
|
||||
ActiveRadarrBlock::AddMovieSearchResults.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1018,17 +1018,17 @@ mod tests {
|
||||
app.should_ignore_quit_key = true;
|
||||
|
||||
AddMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert!(app.should_ignore_quit_key);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddMovieSearchInput.into()
|
||||
ActiveRadarrBlock::AddMovieSearchInput.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1042,20 +1042,20 @@ mod tests {
|
||||
BiMap::from_iter([(1, "B - Test 2".to_owned()), (0, "A - Test 1".to_owned())]);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchResults,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchResults,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddMoviePrompt.into()
|
||||
ActiveRadarrBlock::AddMoviePrompt.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::AddMovieSelectRootFolder
|
||||
ActiveRadarrBlock::AddMovieSelectRootFolder
|
||||
);
|
||||
assert!(app.data.radarr_data.add_movie_modal.is_some());
|
||||
assert!(!app
|
||||
@@ -1107,16 +1107,16 @@ mod tests {
|
||||
add_searched_movies.set_items(vec![AddMovieSearchResult::default()]);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchResults,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchResults,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddMovieSearchResults.into()
|
||||
ActiveRadarrBlock::AddMovieSearchResults.into()
|
||||
);
|
||||
assert!(app.data.radarr_data.add_movie_modal.is_none());
|
||||
}
|
||||
@@ -1126,16 +1126,16 @@ mod tests {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::AddMovieSearchResults.into());
|
||||
AddMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchResults,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchResults,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddMovieSearchResults.into()
|
||||
ActiveRadarrBlock::AddMovieSearchResults.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1152,16 +1152,16 @@ mod tests {
|
||||
.set_items(vec![Movie::default()]);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchResults,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchResults,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddMovieAlreadyInLibrary.into()
|
||||
ActiveRadarrBlock::AddMovieAlreadyInLibrary.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1178,14 +1178,14 @@ mod tests {
|
||||
.set_index(ADD_MOVIE_SELECTION_BLOCKS.len() - 1);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMoviePrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
}
|
||||
|
||||
@@ -1204,14 +1204,14 @@ mod tests {
|
||||
.set_index(ADD_MOVIE_SELECTION_BLOCKS.len() - 1);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMoviePrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
Some(RadarrEvent::AddMovie(None))
|
||||
@@ -1241,16 +1241,16 @@ mod tests {
|
||||
app.data.radarr_data.selected_block.set_index(index);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMoviePrompt,
|
||||
&Some(ActiveRadarrBlock::CollectionDetails),
|
||||
ActiveRadarrBlock::AddMoviePrompt,
|
||||
Some(ActiveRadarrBlock::CollectionDetails),
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&(selected_block, Some(ActiveRadarrBlock::CollectionDetails)).into()
|
||||
(selected_block, Some(ActiveRadarrBlock::CollectionDetails)).into()
|
||||
);
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
|
||||
@@ -1275,16 +1275,16 @@ mod tests {
|
||||
app.push_navigation_stack(active_radarr_block.into());
|
||||
|
||||
AddMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&Some(ActiveRadarrBlock::CollectionDetails),
|
||||
active_radarr_block,
|
||||
Some(ActiveRadarrBlock::CollectionDetails),
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddMoviePrompt.into()
|
||||
ActiveRadarrBlock::AddMoviePrompt.into()
|
||||
);
|
||||
|
||||
if active_radarr_block == ActiveRadarrBlock::AddMovieTagsInput {
|
||||
@@ -1315,15 +1315,15 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::AddMovieSearchInput.into());
|
||||
|
||||
AddMovieHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1336,17 +1336,17 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::AddMovieTagsInput.into());
|
||||
|
||||
AddMovieHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddMoviePrompt.into()
|
||||
ActiveRadarrBlock::AddMoviePrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1368,11 +1368,11 @@ mod tests {
|
||||
));
|
||||
app.data.radarr_data.add_searched_movies = Some(add_searched_movies);
|
||||
|
||||
AddMovieHandler::with(&ESC_KEY, &mut app, &active_radarr_block, &None).handle();
|
||||
AddMovieHandler::with(ESC_KEY, &mut app, active_radarr_block, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddMovieSearchInput.into()
|
||||
ActiveRadarrBlock::AddMovieSearchInput.into()
|
||||
);
|
||||
assert!(app.data.radarr_data.add_searched_movies.is_none());
|
||||
assert!(app.should_ignore_quit_key);
|
||||
@@ -1386,16 +1386,16 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::AddMovieAlreadyInLibrary.into());
|
||||
|
||||
AddMovieHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieAlreadyInLibrary,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieAlreadyInLibrary,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddMovieSearchResults.into()
|
||||
ActiveRadarrBlock::AddMovieSearchResults.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1407,18 +1407,12 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::AddMovieSearchResults.into());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::AddMoviePrompt.into());
|
||||
|
||||
AddMovieHandler::with(
|
||||
&ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMoviePrompt,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
AddMovieHandler::with(ESC_KEY, &mut app, ActiveRadarrBlock::AddMoviePrompt, None).handle();
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddMovieSearchResults.into()
|
||||
ActiveRadarrBlock::AddMovieSearchResults.into()
|
||||
);
|
||||
assert!(app.data.radarr_data.add_movie_modal.is_none());
|
||||
}
|
||||
@@ -1432,17 +1426,17 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::AddMovieTagsInput.into());
|
||||
|
||||
AddMovieHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddMoviePrompt.into()
|
||||
ActiveRadarrBlock::AddMoviePrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1473,16 +1467,16 @@ mod tests {
|
||||
);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&Some(ActiveRadarrBlock::CollectionDetails),
|
||||
active_radarr_block,
|
||||
Some(ActiveRadarrBlock::CollectionDetails),
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&(
|
||||
(
|
||||
ActiveRadarrBlock::AddMoviePrompt,
|
||||
Some(ActiveRadarrBlock::CollectionDetails),
|
||||
)
|
||||
@@ -1507,10 +1501,10 @@ mod tests {
|
||||
app.data.radarr_data.add_movie_search = Some("Test".into());
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
DEFAULT_KEYBINDINGS.backspace.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1529,10 +1523,10 @@ mod tests {
|
||||
});
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
DEFAULT_KEYBINDINGS.backspace.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1555,10 +1549,10 @@ mod tests {
|
||||
app.data.radarr_data.add_movie_search = Some(HorizontallyScrollableText::default());
|
||||
|
||||
AddMovieHandler::with(
|
||||
&Key::Char('h'),
|
||||
Key::Char('h'),
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieSearchInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieSearchInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1574,10 +1568,10 @@ mod tests {
|
||||
app.data.radarr_data.add_movie_modal = Some(AddMovieModal::default());
|
||||
|
||||
AddMovieHandler::with(
|
||||
&Key::Char('h'),
|
||||
Key::Char('h'),
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMovieTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMovieTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1608,14 +1602,14 @@ mod tests {
|
||||
.set_index(ADD_MOVIE_SELECTION_BLOCKS.len() - 1);
|
||||
|
||||
AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.confirm.key,
|
||||
DEFAULT_KEYBINDINGS.confirm.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMoviePrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
Some(RadarrEvent::AddMovie(None))
|
||||
@@ -1628,9 +1622,9 @@ mod tests {
|
||||
fn test_add_movie_handler_accepts() {
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if ADD_MOVIE_BLOCKS.contains(&active_radarr_block) {
|
||||
assert!(AddMovieHandler::accepts(&active_radarr_block));
|
||||
assert!(AddMovieHandler::accepts(active_radarr_block));
|
||||
} else {
|
||||
assert!(!AddMovieHandler::accepts(&active_radarr_block));
|
||||
assert!(!AddMovieHandler::accepts(active_radarr_block));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1641,10 +1635,10 @@ mod tests {
|
||||
app.is_loading = true;
|
||||
|
||||
let handler = AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMoviePrompt,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -1656,10 +1650,10 @@ mod tests {
|
||||
app.is_loading = false;
|
||||
|
||||
let handler = AddMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddMoviePrompt,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
|
||||
@@ -10,22 +10,22 @@ use crate::network::radarr_network::RadarrEvent;
|
||||
mod delete_movie_handler_tests;
|
||||
|
||||
pub(super) struct DeleteMovieHandler<'a, 'b> {
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_radarr_block: &'a ActiveRadarrBlock,
|
||||
_context: &'a Option<ActiveRadarrBlock>,
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DeleteMovieHandler<'a, 'b> {
|
||||
fn accepts(active_block: &'a ActiveRadarrBlock) -> bool {
|
||||
DELETE_MOVIE_BLOCKS.contains(active_block)
|
||||
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
||||
DELETE_MOVIE_BLOCKS.contains(&active_block)
|
||||
}
|
||||
|
||||
fn with(
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_block: &'a ActiveRadarrBlock,
|
||||
_context: &'a Option<ActiveRadarrBlock>,
|
||||
active_block: ActiveRadarrBlock,
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
) -> Self {
|
||||
DeleteMovieHandler {
|
||||
key,
|
||||
@@ -35,7 +35,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DeleteMovieHandler<'
|
||||
}
|
||||
}
|
||||
|
||||
fn get_key(&self) -> &Key {
|
||||
fn get_key(&self) -> Key {
|
||||
self.key
|
||||
}
|
||||
|
||||
@@ -44,13 +44,13 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DeleteMovieHandler<'
|
||||
}
|
||||
|
||||
fn handle_scroll_up(&mut self) {
|
||||
if *self.active_radarr_block == ActiveRadarrBlock::DeleteMoviePrompt {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::DeleteMoviePrompt {
|
||||
self.app.data.radarr_data.selected_block.previous();
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_scroll_down(&mut self) {
|
||||
if *self.active_radarr_block == ActiveRadarrBlock::DeleteMoviePrompt {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::DeleteMoviePrompt {
|
||||
self.app.data.radarr_data.selected_block.next();
|
||||
}
|
||||
}
|
||||
@@ -62,13 +62,13 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DeleteMovieHandler<'
|
||||
fn handle_delete(&mut self) {}
|
||||
|
||||
fn handle_left_right_action(&mut self) {
|
||||
if *self.active_radarr_block == ActiveRadarrBlock::DeleteMoviePrompt {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::DeleteMoviePrompt {
|
||||
handle_prompt_toggle(self.app, self.key);
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_submit(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::DeleteMoviePrompt {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::DeleteMoviePrompt {
|
||||
match self.app.data.radarr_data.selected_block.get_active_block() {
|
||||
ActiveRadarrBlock::DeleteMovieConfirmPrompt => {
|
||||
if self.app.data.radarr_data.prompt_confirm {
|
||||
@@ -94,7 +94,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DeleteMovieHandler<'
|
||||
}
|
||||
|
||||
fn handle_esc(&mut self) {
|
||||
if *self.active_radarr_block == ActiveRadarrBlock::DeleteMoviePrompt {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::DeleteMoviePrompt {
|
||||
self.app.pop_navigation_stack();
|
||||
self.app.data.radarr_data.reset_delete_movie_preferences();
|
||||
self.app.data.radarr_data.prompt_confirm = false;
|
||||
@@ -102,10 +102,10 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DeleteMovieHandler<'
|
||||
}
|
||||
|
||||
fn handle_char_key_event(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::DeleteMoviePrompt
|
||||
if self.active_radarr_block == ActiveRadarrBlock::DeleteMoviePrompt
|
||||
&& self.app.data.radarr_data.selected_block.get_active_block()
|
||||
== &ActiveRadarrBlock::DeleteMovieConfirmPrompt
|
||||
&& *self.key == DEFAULT_KEYBINDINGS.confirm.key
|
||||
== ActiveRadarrBlock::DeleteMovieConfirmPrompt
|
||||
&& self.key == DEFAULT_KEYBINDINGS.confirm.key
|
||||
{
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action = Some(RadarrEvent::DeleteMovie(None));
|
||||
|
||||
@@ -25,18 +25,17 @@ mod tests {
|
||||
BlockSelectionState::new(&DELETE_MOVIE_SELECTION_BLOCKS);
|
||||
app.data.radarr_data.selected_block.next();
|
||||
|
||||
DeleteMovieHandler::with(&key, &mut app, &ActiveRadarrBlock::DeleteMoviePrompt, &None)
|
||||
.handle();
|
||||
DeleteMovieHandler::with(key, &mut app, ActiveRadarrBlock::DeleteMoviePrompt, None).handle();
|
||||
|
||||
if key == Key::Up {
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::DeleteMovieToggleDeleteFile
|
||||
ActiveRadarrBlock::DeleteMovieToggleDeleteFile
|
||||
);
|
||||
} else {
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::DeleteMovieConfirmPrompt
|
||||
ActiveRadarrBlock::DeleteMovieConfirmPrompt
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -51,12 +50,11 @@ mod tests {
|
||||
BlockSelectionState::new(&DELETE_MOVIE_SELECTION_BLOCKS);
|
||||
app.data.radarr_data.selected_block.next();
|
||||
|
||||
DeleteMovieHandler::with(&key, &mut app, &ActiveRadarrBlock::DeleteMoviePrompt, &None)
|
||||
.handle();
|
||||
DeleteMovieHandler::with(key, &mut app, ActiveRadarrBlock::DeleteMoviePrompt, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::DeleteMovieToggleAddListExclusion
|
||||
ActiveRadarrBlock::DeleteMovieToggleAddListExclusion
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -70,13 +68,11 @@ mod tests {
|
||||
fn test_left_right_prompt_toggle(#[values(Key::Left, Key::Right)] key: Key) {
|
||||
let mut app = App::default();
|
||||
|
||||
DeleteMovieHandler::with(&key, &mut app, &ActiveRadarrBlock::DeleteMoviePrompt, &None)
|
||||
.handle();
|
||||
DeleteMovieHandler::with(key, &mut app, ActiveRadarrBlock::DeleteMoviePrompt, None).handle();
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
DeleteMovieHandler::with(&key, &mut app, &ActiveRadarrBlock::DeleteMoviePrompt, &None)
|
||||
.handle();
|
||||
DeleteMovieHandler::with(key, &mut app, ActiveRadarrBlock::DeleteMoviePrompt, None).handle();
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
@@ -109,14 +105,14 @@ mod tests {
|
||||
app.data.radarr_data.add_list_exclusion = true;
|
||||
|
||||
DeleteMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteMoviePrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
assert!(!app.data.radarr_data.delete_movie_files);
|
||||
@@ -140,14 +136,14 @@ mod tests {
|
||||
.set_index(DELETE_MOVIE_SELECTION_BLOCKS.len() - 1);
|
||||
|
||||
DeleteMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteMoviePrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
Some(RadarrEvent::DeleteMovie(None))
|
||||
@@ -169,16 +165,16 @@ mod tests {
|
||||
app.data.radarr_data.add_list_exclusion = true;
|
||||
|
||||
DeleteMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteMoviePrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::DeleteMoviePrompt.into()
|
||||
ActiveRadarrBlock::DeleteMoviePrompt.into()
|
||||
);
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
assert!(!app.should_refresh);
|
||||
@@ -196,25 +192,25 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::DeleteMoviePrompt.into());
|
||||
|
||||
DeleteMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteMoviePrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), ¤t_route);
|
||||
assert_eq!(app.get_current_route(), current_route);
|
||||
assert_eq!(app.data.radarr_data.delete_movie_files, true);
|
||||
|
||||
DeleteMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteMoviePrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), ¤t_route);
|
||||
assert_eq!(app.get_current_route(), current_route);
|
||||
assert_eq!(app.data.radarr_data.delete_movie_files, false);
|
||||
}
|
||||
}
|
||||
@@ -236,14 +232,14 @@ mod tests {
|
||||
app.data.radarr_data.add_list_exclusion = true;
|
||||
|
||||
DeleteMovieHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteMoviePrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
assert!(!app.data.radarr_data.delete_movie_files);
|
||||
assert!(!app.data.radarr_data.add_list_exclusion);
|
||||
@@ -276,14 +272,14 @@ mod tests {
|
||||
.set_index(DELETE_MOVIE_SELECTION_BLOCKS.len() - 1);
|
||||
|
||||
DeleteMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.confirm.key,
|
||||
DEFAULT_KEYBINDINGS.confirm.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteMoviePrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
Some(RadarrEvent::DeleteMovie(None))
|
||||
@@ -299,9 +295,9 @@ mod tests {
|
||||
fn test_delete_movie_handler_accepts() {
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if DELETE_MOVIE_BLOCKS.contains(&active_radarr_block) {
|
||||
assert!(DeleteMovieHandler::accepts(&active_radarr_block));
|
||||
assert!(DeleteMovieHandler::accepts(active_radarr_block));
|
||||
} else {
|
||||
assert!(!DeleteMovieHandler::accepts(&active_radarr_block));
|
||||
assert!(!DeleteMovieHandler::accepts(active_radarr_block));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -312,10 +308,10 @@ mod tests {
|
||||
app.is_loading = true;
|
||||
|
||||
let handler = DeleteMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteMoviePrompt,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -327,10 +323,10 @@ mod tests {
|
||||
app.is_loading = false;
|
||||
|
||||
let handler = DeleteMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteMoviePrompt,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
|
||||
@@ -12,22 +12,22 @@ use crate::{handle_text_box_keys, handle_text_box_left_right_keys};
|
||||
mod edit_movie_handler_tests;
|
||||
|
||||
pub(super) struct EditMovieHandler<'a, 'b> {
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_radarr_block: &'a ActiveRadarrBlock,
|
||||
context: &'a Option<ActiveRadarrBlock>,
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditMovieHandler<'a, 'b> {
|
||||
fn accepts(active_block: &'a ActiveRadarrBlock) -> bool {
|
||||
EDIT_MOVIE_BLOCKS.contains(active_block)
|
||||
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
||||
EDIT_MOVIE_BLOCKS.contains(&active_block)
|
||||
}
|
||||
|
||||
fn with(
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_block: &'a ActiveRadarrBlock,
|
||||
context: &'a Option<ActiveRadarrBlock>,
|
||||
active_block: ActiveRadarrBlock,
|
||||
context: Option<ActiveRadarrBlock>,
|
||||
) -> EditMovieHandler<'a, 'b> {
|
||||
EditMovieHandler {
|
||||
key,
|
||||
@@ -37,7 +37,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditMovieHandler<'a,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_key(&self) -> &Key {
|
||||
fn get_key(&self) -> Key {
|
||||
self.key
|
||||
}
|
||||
|
||||
@@ -231,16 +231,16 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditMovieHandler<'a,
|
||||
ActiveRadarrBlock::EditMovieSelectMinimumAvailability
|
||||
| ActiveRadarrBlock::EditMovieSelectQualityProfile => self.app.push_navigation_stack(
|
||||
(
|
||||
*self.app.data.radarr_data.selected_block.get_active_block(),
|
||||
*self.context,
|
||||
self.app.data.radarr_data.selected_block.get_active_block(),
|
||||
self.context,
|
||||
)
|
||||
.into(),
|
||||
),
|
||||
ActiveRadarrBlock::EditMoviePathInput | ActiveRadarrBlock::EditMovieTagsInput => {
|
||||
self.app.push_navigation_stack(
|
||||
(
|
||||
*self.app.data.radarr_data.selected_block.get_active_block(),
|
||||
*self.context,
|
||||
self.app.data.radarr_data.selected_block.get_active_block(),
|
||||
self.context,
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
@@ -329,8 +329,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditMovieHandler<'a,
|
||||
}
|
||||
ActiveRadarrBlock::EditMoviePrompt => {
|
||||
if self.app.data.radarr_data.selected_block.get_active_block()
|
||||
== &ActiveRadarrBlock::EditMovieConfirmPrompt
|
||||
&& *key == DEFAULT_KEYBINDINGS.confirm.key
|
||||
== ActiveRadarrBlock::EditMovieConfirmPrompt
|
||||
&& key == DEFAULT_KEYBINDINGS.confirm.key
|
||||
{
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action = Some(RadarrEvent::EditMovie(None));
|
||||
|
||||
@@ -42,10 +42,10 @@ mod tests {
|
||||
if key == Key::Up {
|
||||
for i in (0..minimum_availability_vec.len()).rev() {
|
||||
EditMovieHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMovieSelectMinimumAvailability,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMovieSelectMinimumAvailability,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -64,10 +64,10 @@ mod tests {
|
||||
} else {
|
||||
for i in 0..minimum_availability_vec.len() {
|
||||
EditMovieHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMovieSelectMinimumAvailability,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMovieSelectMinimumAvailability,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -102,10 +102,10 @@ mod tests {
|
||||
.set_items(vec!["Test 1".to_owned(), "Test 2".to_owned()]);
|
||||
|
||||
EditMovieHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMovieSelectQualityProfile,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMovieSelectQualityProfile,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -122,10 +122,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditMovieHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMovieSelectQualityProfile,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMovieSelectQualityProfile,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -149,17 +149,17 @@ mod tests {
|
||||
app.data.radarr_data.selected_block = BlockSelectionState::new(&EDIT_MOVIE_SELECTION_BLOCKS);
|
||||
app.data.radarr_data.selected_block.next();
|
||||
|
||||
EditMovieHandler::with(&key, &mut app, &ActiveRadarrBlock::EditMoviePrompt, &None).handle();
|
||||
EditMovieHandler::with(key, &mut app, ActiveRadarrBlock::EditMoviePrompt, None).handle();
|
||||
|
||||
if key == Key::Up {
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::EditMovieToggleMonitored
|
||||
ActiveRadarrBlock::EditMovieToggleMonitored
|
||||
);
|
||||
} else {
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::EditMovieSelectQualityProfile
|
||||
ActiveRadarrBlock::EditMovieSelectQualityProfile
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -172,11 +172,11 @@ mod tests {
|
||||
app.data.radarr_data.selected_block = BlockSelectionState::new(&EDIT_MOVIE_SELECTION_BLOCKS);
|
||||
app.data.radarr_data.selected_block.next();
|
||||
|
||||
EditMovieHandler::with(&key, &mut app, &ActiveRadarrBlock::EditMoviePrompt, &None).handle();
|
||||
EditMovieHandler::with(key, &mut app, ActiveRadarrBlock::EditMoviePrompt, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::EditMovieSelectMinimumAvailability
|
||||
ActiveRadarrBlock::EditMovieSelectMinimumAvailability
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -205,10 +205,10 @@ mod tests {
|
||||
.set_items(minimum_availability_vec.clone());
|
||||
|
||||
EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMovieSelectMinimumAvailability,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMovieSelectMinimumAvailability,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -225,10 +225,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMovieSelectMinimumAvailability,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMovieSelectMinimumAvailability,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -263,10 +263,10 @@ mod tests {
|
||||
]);
|
||||
|
||||
EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMovieSelectQualityProfile,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMovieSelectQualityProfile,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -283,10 +283,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMovieSelectQualityProfile,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMovieSelectQualityProfile,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -312,10 +312,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePathInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMoviePathInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -333,10 +333,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePathInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMoviePathInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -363,10 +363,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMovieTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMovieTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -384,10 +384,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMovieTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMovieTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -418,11 +418,11 @@ mod tests {
|
||||
fn test_left_right_prompt_toggle(#[values(Key::Left, Key::Right)] key: Key) {
|
||||
let mut app = App::default();
|
||||
|
||||
EditMovieHandler::with(&key, &mut app, &ActiveRadarrBlock::EditMoviePrompt, &None).handle();
|
||||
EditMovieHandler::with(key, &mut app, ActiveRadarrBlock::EditMoviePrompt, None).handle();
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
EditMovieHandler::with(&key, &mut app, &ActiveRadarrBlock::EditMoviePrompt, &None).handle();
|
||||
EditMovieHandler::with(key, &mut app, ActiveRadarrBlock::EditMoviePrompt, None).handle();
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
@@ -436,10 +436,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePathInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMoviePathInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -457,10 +457,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePathInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMoviePathInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -487,10 +487,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMovieTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMovieTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -508,10 +508,10 @@ mod tests {
|
||||
);
|
||||
|
||||
EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMovieTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMovieTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -557,10 +557,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditMoviePathInput.into());
|
||||
|
||||
EditMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePathInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMoviePathInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -576,7 +576,7 @@ mod tests {
|
||||
.is_empty());
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditMoviePrompt.into()
|
||||
ActiveRadarrBlock::EditMoviePrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -592,10 +592,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditMoviePathInput.into());
|
||||
|
||||
EditMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMovieTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMovieTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -611,7 +611,7 @@ mod tests {
|
||||
.is_empty());
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditMoviePrompt.into()
|
||||
ActiveRadarrBlock::EditMoviePrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -629,14 +629,14 @@ mod tests {
|
||||
.set_index(EDIT_COLLECTION_SELECTION_BLOCKS.len() - 1);
|
||||
|
||||
EditMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMoviePrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
}
|
||||
|
||||
@@ -655,14 +655,14 @@ mod tests {
|
||||
.set_index(EDIT_COLLECTION_SELECTION_BLOCKS.len() - 1);
|
||||
|
||||
EditMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMoviePrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
Some(RadarrEvent::EditMovie(None))
|
||||
@@ -681,16 +681,16 @@ mod tests {
|
||||
app.data.radarr_data.prompt_confirm = true;
|
||||
|
||||
EditMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMoviePrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditMoviePrompt.into()
|
||||
ActiveRadarrBlock::EditMoviePrompt.into()
|
||||
);
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
assert!(!app.should_refresh);
|
||||
@@ -708,14 +708,14 @@ mod tests {
|
||||
app.push_navigation_stack(current_route);
|
||||
|
||||
EditMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePrompt,
|
||||
&Some(ActiveRadarrBlock::Movies),
|
||||
ActiveRadarrBlock::EditMoviePrompt,
|
||||
Some(ActiveRadarrBlock::Movies),
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), ¤t_route);
|
||||
assert_eq!(app.get_current_route(), current_route);
|
||||
assert_eq!(
|
||||
app
|
||||
.data
|
||||
@@ -728,14 +728,14 @@ mod tests {
|
||||
);
|
||||
|
||||
EditMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePrompt,
|
||||
&Some(ActiveRadarrBlock::Movies),
|
||||
ActiveRadarrBlock::EditMoviePrompt,
|
||||
Some(ActiveRadarrBlock::Movies),
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), ¤t_route);
|
||||
assert_eq!(app.get_current_route(), current_route);
|
||||
assert_eq!(
|
||||
app
|
||||
.data
|
||||
@@ -770,16 +770,16 @@ mod tests {
|
||||
app.data.radarr_data.selected_block.set_index(index);
|
||||
|
||||
EditMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePrompt,
|
||||
&Some(ActiveRadarrBlock::Movies),
|
||||
ActiveRadarrBlock::EditMoviePrompt,
|
||||
Some(ActiveRadarrBlock::Movies),
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&(selected_block, Some(ActiveRadarrBlock::Movies)).into()
|
||||
(selected_block, Some(ActiveRadarrBlock::Movies)).into()
|
||||
);
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
|
||||
@@ -808,16 +808,16 @@ mod tests {
|
||||
app.data.radarr_data.selected_block.set_index(index);
|
||||
|
||||
EditMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePrompt,
|
||||
&Some(ActiveRadarrBlock::Movies),
|
||||
ActiveRadarrBlock::EditMoviePrompt,
|
||||
Some(ActiveRadarrBlock::Movies),
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&(
|
||||
(
|
||||
ActiveRadarrBlock::EditMoviePrompt,
|
||||
Some(ActiveRadarrBlock::Movies),
|
||||
)
|
||||
@@ -843,16 +843,16 @@ mod tests {
|
||||
app.push_navigation_stack(active_radarr_block.into());
|
||||
|
||||
EditMovieHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&Some(ActiveRadarrBlock::Movies),
|
||||
active_radarr_block,
|
||||
Some(ActiveRadarrBlock::Movies),
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditMoviePrompt.into()
|
||||
ActiveRadarrBlock::EditMoviePrompt.into()
|
||||
);
|
||||
|
||||
if active_radarr_block == ActiveRadarrBlock::EditMoviePathInput
|
||||
@@ -888,12 +888,12 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::EditMoviePrompt.into());
|
||||
app.push_navigation_stack(active_radarr_block.into());
|
||||
|
||||
EditMovieHandler::with(&ESC_KEY, &mut app, &active_radarr_block, &None).handle();
|
||||
EditMovieHandler::with(ESC_KEY, &mut app, active_radarr_block, None).handle();
|
||||
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::EditMoviePrompt.into()
|
||||
ActiveRadarrBlock::EditMoviePrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -904,15 +904,9 @@ mod tests {
|
||||
app.data.radarr_data = create_test_radarr_data();
|
||||
app.data.radarr_data.edit_movie_modal = Some(EditMovieModal::default());
|
||||
|
||||
EditMovieHandler::with(
|
||||
&ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePrompt,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
EditMovieHandler::with(ESC_KEY, &mut app, ActiveRadarrBlock::EditMoviePrompt, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
|
||||
assert!(app.data.radarr_data.edit_movie_modal.is_none());
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
@@ -932,9 +926,9 @@ mod tests {
|
||||
app.data.radarr_data = create_test_radarr_data();
|
||||
app.push_navigation_stack(active_radarr_block.into());
|
||||
|
||||
EditMovieHandler::with(&ESC_KEY, &mut app, &active_radarr_block, &None).handle();
|
||||
EditMovieHandler::with(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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -960,10 +954,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
DEFAULT_KEYBINDINGS.backspace.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePathInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMoviePathInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -989,10 +983,10 @@ mod tests {
|
||||
});
|
||||
|
||||
EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
DEFAULT_KEYBINDINGS.backspace.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMovieTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMovieTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1015,10 +1009,10 @@ mod tests {
|
||||
app.data.radarr_data.edit_movie_modal = Some(EditMovieModal::default());
|
||||
|
||||
EditMovieHandler::with(
|
||||
&Key::Char('h'),
|
||||
Key::Char('h'),
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePathInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMoviePathInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1041,10 +1035,10 @@ mod tests {
|
||||
app.data.radarr_data.edit_movie_modal = Some(EditMovieModal::default());
|
||||
|
||||
EditMovieHandler::with(
|
||||
&Key::Char('h'),
|
||||
Key::Char('h'),
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMovieTagsInput,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMovieTagsInput,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1075,14 +1069,14 @@ mod tests {
|
||||
.set_index(EDIT_COLLECTION_SELECTION_BLOCKS.len() - 1);
|
||||
|
||||
EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.confirm.key,
|
||||
DEFAULT_KEYBINDINGS.confirm.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMoviePrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
Some(RadarrEvent::EditMovie(None))
|
||||
@@ -1096,9 +1090,9 @@ mod tests {
|
||||
fn test_edit_movie_handler_accepts() {
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if EDIT_MOVIE_BLOCKS.contains(&active_radarr_block) {
|
||||
assert!(EditMovieHandler::accepts(&active_radarr_block));
|
||||
assert!(EditMovieHandler::accepts(active_radarr_block));
|
||||
} else {
|
||||
assert!(!EditMovieHandler::accepts(&active_radarr_block));
|
||||
assert!(!EditMovieHandler::accepts(active_radarr_block));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1109,10 +1103,10 @@ mod tests {
|
||||
app.is_loading = true;
|
||||
|
||||
let handler = EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMoviePrompt,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -1124,10 +1118,10 @@ mod tests {
|
||||
app.is_loading = false;
|
||||
|
||||
let handler = EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMoviePrompt,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -1140,10 +1134,10 @@ mod tests {
|
||||
app.data.radarr_data.edit_movie_modal = Some(EditMovieModal::default());
|
||||
|
||||
let handler = EditMovieHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::EditMoviePrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::EditMoviePrompt,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
|
||||
@@ -53,7 +53,7 @@ mod tests {
|
||||
HorizontallyScrollableText
|
||||
));
|
||||
|
||||
LibraryHandler::with(&key, &mut app, &ActiveRadarrBlock::Movies, &None).handle();
|
||||
LibraryHandler::with(key, &mut app, ActiveRadarrBlock::Movies, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -66,7 +66,7 @@ mod tests {
|
||||
"Test 1"
|
||||
);
|
||||
|
||||
LibraryHandler::with(&key, &mut app, &ActiveRadarrBlock::Movies, &None).handle();
|
||||
LibraryHandler::with(key, &mut app, ActiveRadarrBlock::Movies, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -90,8 +90,7 @@ mod tests {
|
||||
|
||||
if key == Key::Up {
|
||||
for i in (0..movie_field_vec.len()).rev() {
|
||||
LibraryHandler::with(&key, &mut app, &ActiveRadarrBlock::MoviesSortPrompt, &None)
|
||||
.handle();
|
||||
LibraryHandler::with(key, &mut app, ActiveRadarrBlock::MoviesSortPrompt, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app
|
||||
@@ -107,8 +106,7 @@ mod tests {
|
||||
}
|
||||
} else {
|
||||
for i in 0..movie_field_vec.len() {
|
||||
LibraryHandler::with(&key, &mut app, &ActiveRadarrBlock::MoviesSortPrompt, &None)
|
||||
.handle();
|
||||
LibraryHandler::with(key, &mut app, ActiveRadarrBlock::MoviesSortPrompt, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app
|
||||
@@ -158,10 +156,10 @@ mod tests {
|
||||
));
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -177,10 +175,10 @@ mod tests {
|
||||
);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -207,10 +205,10 @@ mod tests {
|
||||
app.data.radarr_data.movies.search = Some("Test".into());
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SearchMovie,
|
||||
&None,
|
||||
ActiveRadarrBlock::SearchMovie,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -228,10 +226,10 @@ mod tests {
|
||||
);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SearchMovie,
|
||||
&None,
|
||||
ActiveRadarrBlock::SearchMovie,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -260,10 +258,10 @@ mod tests {
|
||||
app.data.radarr_data.movies.filter = Some("Test".into());
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::FilterMovies,
|
||||
&None,
|
||||
ActiveRadarrBlock::FilterMovies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -281,10 +279,10 @@ mod tests {
|
||||
);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::FilterMovies,
|
||||
&None,
|
||||
ActiveRadarrBlock::FilterMovies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -309,10 +307,10 @@ mod tests {
|
||||
app.data.radarr_data.movies.sorting(sort_options());
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MoviesSortPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::MoviesSortPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -329,10 +327,10 @@ mod tests {
|
||||
);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MoviesSortPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::MoviesSortPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -392,9 +390,9 @@ mod tests {
|
||||
.movies
|
||||
.set_items(vec![Movie::default()]);
|
||||
|
||||
LibraryHandler::with(&DELETE_KEY, &mut app, &ActiveRadarrBlock::Movies, &None).handle();
|
||||
LibraryHandler::with(DELETE_KEY, &mut app, ActiveRadarrBlock::Movies, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,18 +409,18 @@ mod tests {
|
||||
app.data.radarr_data.main_tabs.set_index(0);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.main_tabs.get_active_route(),
|
||||
&ActiveRadarrBlock::System.into()
|
||||
ActiveRadarrBlock::System.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::System.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::System.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -432,20 +430,20 @@ mod tests {
|
||||
app.data.radarr_data.main_tabs.set_index(0);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.main_tabs.get_active_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Collections.into()
|
||||
ActiveRadarrBlock::Collections.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -456,20 +454,20 @@ mod tests {
|
||||
let mut app = App::default();
|
||||
|
||||
LibraryHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::UpdateAllMoviesPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::UpdateAllMoviesPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
LibraryHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::UpdateAllMoviesPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::UpdateAllMoviesPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -482,10 +480,10 @@ mod tests {
|
||||
app.data.radarr_data.movies.search = Some("Test".into());
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SearchMovie,
|
||||
&None,
|
||||
ActiveRadarrBlock::SearchMovie,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -503,10 +501,10 @@ mod tests {
|
||||
);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SearchMovie,
|
||||
&None,
|
||||
ActiveRadarrBlock::SearchMovie,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -530,10 +528,10 @@ mod tests {
|
||||
app.data.radarr_data.movies.filter = Some("Test".into());
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::FilterMovies,
|
||||
&None,
|
||||
ActiveRadarrBlock::FilterMovies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -551,10 +549,10 @@ mod tests {
|
||||
);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::FilterMovies,
|
||||
&None,
|
||||
ActiveRadarrBlock::FilterMovies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -592,11 +590,11 @@ mod tests {
|
||||
.movies
|
||||
.set_items(vec![Movie::default()]);
|
||||
|
||||
LibraryHandler::with(&SUBMIT_KEY, &mut app, &ActiveRadarrBlock::Movies, &None).handle();
|
||||
LibraryHandler::with(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Movies, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::MovieDetails.into()
|
||||
ActiveRadarrBlock::MovieDetails.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -611,9 +609,9 @@ mod tests {
|
||||
.movies
|
||||
.set_items(vec![Movie::default()]);
|
||||
|
||||
LibraryHandler::with(&SUBMIT_KEY, &mut app, &ActiveRadarrBlock::Movies, &None).handle();
|
||||
LibraryHandler::with(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Movies, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -631,19 +629,13 @@ mod tests {
|
||||
));
|
||||
app.data.radarr_data.movies.search = Some("Test 2".into());
|
||||
|
||||
LibraryHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SearchMovie,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
LibraryHandler::with(SUBMIT_KEY, &mut app, ActiveRadarrBlock::SearchMovie, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.movies.current_selection().title.text,
|
||||
"Test 2"
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -661,13 +653,7 @@ mod tests {
|
||||
));
|
||||
app.data.radarr_data.movies.search = Some("Test 5".into());
|
||||
|
||||
LibraryHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SearchMovie,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
LibraryHandler::with(SUBMIT_KEY, &mut app, ActiveRadarrBlock::SearchMovie, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.movies.current_selection().title.text,
|
||||
@@ -675,7 +661,7 @@ mod tests {
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::SearchMovieError.into()
|
||||
ActiveRadarrBlock::SearchMovieError.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -699,19 +685,13 @@ mod tests {
|
||||
));
|
||||
app.data.radarr_data.movies.search = Some("Test 2".into());
|
||||
|
||||
LibraryHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SearchMovie,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
LibraryHandler::with(SUBMIT_KEY, &mut app, ActiveRadarrBlock::SearchMovie, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.movies.current_selection().title.text,
|
||||
"Test 2"
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -729,13 +709,7 @@ mod tests {
|
||||
));
|
||||
app.data.radarr_data.movies.filter = Some("Test".into());
|
||||
|
||||
LibraryHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::FilterMovies,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
LibraryHandler::with(SUBMIT_KEY, &mut app, ActiveRadarrBlock::FilterMovies, None).handle();
|
||||
|
||||
assert!(app.data.radarr_data.movies.filtered_items.is_some());
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
@@ -754,7 +728,7 @@ mod tests {
|
||||
app.data.radarr_data.movies.current_selection().title.text,
|
||||
"Test 1"
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -772,19 +746,13 @@ mod tests {
|
||||
));
|
||||
app.data.radarr_data.movies.filter = Some("Test 5".into());
|
||||
|
||||
LibraryHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::FilterMovies,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
LibraryHandler::with(SUBMIT_KEY, &mut app, ActiveRadarrBlock::FilterMovies, None).handle();
|
||||
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert!(app.data.radarr_data.movies.filtered_items.is_none());
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::FilterMoviesError.into()
|
||||
ActiveRadarrBlock::FilterMoviesError.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -801,10 +769,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::UpdateAllMoviesPrompt.into());
|
||||
|
||||
LibraryHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::UpdateAllMoviesPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::UpdateAllMoviesPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -813,7 +781,7 @@ mod tests {
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
Some(RadarrEvent::UpdateAllMovies)
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -828,16 +796,16 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::UpdateAllMoviesPrompt.into());
|
||||
|
||||
LibraryHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::UpdateAllMoviesPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::UpdateAllMoviesPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -854,14 +822,14 @@ mod tests {
|
||||
expected_vec.reverse();
|
||||
|
||||
LibraryHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MoviesSortPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::MoviesSortPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.data.radarr_data.movies.items, expected_vec);
|
||||
}
|
||||
}
|
||||
@@ -889,9 +857,9 @@ mod tests {
|
||||
app.data.radarr_data = create_test_radarr_data();
|
||||
app.data.radarr_data.movies.search = Some("Test".into());
|
||||
|
||||
LibraryHandler::with(&ESC_KEY, &mut app, &active_radarr_block, &None).handle();
|
||||
LibraryHandler::with(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_eq!(app.data.radarr_data.movies.search, None);
|
||||
}
|
||||
@@ -913,9 +881,9 @@ mod tests {
|
||||
..StatefulTable::default()
|
||||
};
|
||||
|
||||
LibraryHandler::with(&ESC_KEY, &mut app, &active_radarr_block, &None).handle();
|
||||
LibraryHandler::with(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_eq!(app.data.radarr_data.movies.filter, None);
|
||||
assert_eq!(app.data.radarr_data.movies.filtered_items, None);
|
||||
@@ -930,14 +898,14 @@ mod tests {
|
||||
app.data.radarr_data.prompt_confirm = true;
|
||||
|
||||
LibraryHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::UpdateAllMoviesPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::UpdateAllMoviesPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
|
||||
@@ -947,15 +915,9 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Movies.into());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::MoviesSortPrompt.into());
|
||||
|
||||
LibraryHandler::with(
|
||||
&ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MoviesSortPrompt,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
LibraryHandler::with(ESC_KEY, &mut app, ActiveRadarrBlock::MoviesSortPrompt, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -974,9 +936,9 @@ mod tests {
|
||||
..StatefulTable::default()
|
||||
};
|
||||
|
||||
LibraryHandler::with(&ESC_KEY, &mut app, &ActiveRadarrBlock::Movies, &None).handle();
|
||||
LibraryHandler::with(ESC_KEY, &mut app, ActiveRadarrBlock::Movies, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
assert!(app.error.text.is_empty());
|
||||
assert_eq!(app.data.radarr_data.movies.search, None);
|
||||
assert_eq!(app.data.radarr_data.movies.filter, None);
|
||||
@@ -1012,16 +974,16 @@ mod tests {
|
||||
.set_items(vec![Movie::default()]);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.search.key,
|
||||
DEFAULT_KEYBINDINGS.search.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::SearchMovie.into()
|
||||
ActiveRadarrBlock::SearchMovie.into()
|
||||
);
|
||||
assert!(app.should_ignore_quit_key);
|
||||
assert_eq!(
|
||||
@@ -1042,14 +1004,14 @@ mod tests {
|
||||
.set_items(vec![Movie::default()]);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.search.key,
|
||||
DEFAULT_KEYBINDINGS.search.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
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_eq!(app.data.radarr_data.movies.search, None);
|
||||
}
|
||||
@@ -1064,16 +1026,16 @@ mod tests {
|
||||
.set_items(vec![Movie::default()]);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.filter.key,
|
||||
DEFAULT_KEYBINDINGS.filter.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::FilterMovies.into()
|
||||
ActiveRadarrBlock::FilterMovies.into()
|
||||
);
|
||||
assert!(app.should_ignore_quit_key);
|
||||
assert!(app.data.radarr_data.movies.filter.is_some());
|
||||
@@ -1091,14 +1053,14 @@ mod tests {
|
||||
.set_items(vec![Movie::default()]);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.filter.key,
|
||||
DEFAULT_KEYBINDINGS.filter.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
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.data.radarr_data.movies.filter.is_none());
|
||||
}
|
||||
@@ -1117,16 +1079,16 @@ mod tests {
|
||||
app.data.radarr_data.movies.filter = Some("Test".into());
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.filter.key,
|
||||
DEFAULT_KEYBINDINGS.filter.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::FilterMovies.into()
|
||||
ActiveRadarrBlock::FilterMovies.into()
|
||||
);
|
||||
assert!(app.should_ignore_quit_key);
|
||||
assert_eq!(
|
||||
@@ -1147,16 +1109,16 @@ mod tests {
|
||||
.set_items(vec![Movie::default()]);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.add.key,
|
||||
DEFAULT_KEYBINDINGS.add.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddMovieSearchInput.into()
|
||||
ActiveRadarrBlock::AddMovieSearchInput.into()
|
||||
);
|
||||
assert!(app.should_ignore_quit_key);
|
||||
assert!(app.data.radarr_data.add_movie_search.is_some());
|
||||
@@ -1174,14 +1136,14 @@ mod tests {
|
||||
.set_items(vec![Movie::default()]);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.add.key,
|
||||
DEFAULT_KEYBINDINGS.add.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
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.data.radarr_data.add_movie_search.is_none());
|
||||
}
|
||||
@@ -1207,14 +1169,14 @@ mod tests {
|
||||
.set_items(vec![Movie::default()]);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.edit.key,
|
||||
DEFAULT_KEYBINDINGS.edit.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
assert!(app.data.radarr_data.edit_movie_modal.is_none());
|
||||
}
|
||||
|
||||
@@ -1228,16 +1190,16 @@ mod tests {
|
||||
.set_items(vec![Movie::default()]);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.update.key,
|
||||
DEFAULT_KEYBINDINGS.update.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::UpdateAllMoviesPrompt.into()
|
||||
ActiveRadarrBlock::UpdateAllMoviesPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1253,14 +1215,14 @@ mod tests {
|
||||
.set_items(vec![Movie::default()]);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.update.key,
|
||||
DEFAULT_KEYBINDINGS.update.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1274,14 +1236,14 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Movies.into());
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.refresh.key,
|
||||
DEFAULT_KEYBINDINGS.refresh.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
assert!(app.should_refresh);
|
||||
}
|
||||
|
||||
@@ -1297,14 +1259,14 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Movies.into());
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.refresh.key,
|
||||
DEFAULT_KEYBINDINGS.refresh.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
assert!(!app.should_refresh);
|
||||
}
|
||||
|
||||
@@ -1319,10 +1281,10 @@ mod tests {
|
||||
.set_items(vec![Movie::default()]);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
DEFAULT_KEYBINDINGS.backspace.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SearchMovie,
|
||||
&None,
|
||||
ActiveRadarrBlock::SearchMovie,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1343,10 +1305,10 @@ mod tests {
|
||||
app.data.radarr_data.movies.filter = Some("Test".into());
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
DEFAULT_KEYBINDINGS.backspace.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::FilterMovies,
|
||||
&None,
|
||||
ActiveRadarrBlock::FilterMovies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1367,10 +1329,10 @@ mod tests {
|
||||
app.data.radarr_data.movies.search = Some(HorizontallyScrollableText::default());
|
||||
|
||||
LibraryHandler::with(
|
||||
&Key::Char('h'),
|
||||
Key::Char('h'),
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SearchMovie,
|
||||
&None,
|
||||
ActiveRadarrBlock::SearchMovie,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1391,10 +1353,10 @@ mod tests {
|
||||
app.data.radarr_data.movies.filter = Some(HorizontallyScrollableText::default());
|
||||
|
||||
LibraryHandler::with(
|
||||
&Key::Char('h'),
|
||||
Key::Char('h'),
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::FilterMovies,
|
||||
&None,
|
||||
ActiveRadarrBlock::FilterMovies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1414,16 +1376,16 @@ mod tests {
|
||||
.set_items(vec![Movie::default()]);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.sort.key,
|
||||
DEFAULT_KEYBINDINGS.sort.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::MoviesSortPrompt.into()
|
||||
ActiveRadarrBlock::MoviesSortPrompt.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.data.radarr_data.movies.sort.as_ref().unwrap().items,
|
||||
@@ -1444,14 +1406,14 @@ mod tests {
|
||||
.set_items(vec![Movie::default()]);
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.sort.key,
|
||||
DEFAULT_KEYBINDINGS.sort.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
assert!(app.data.radarr_data.movies.sort.is_none());
|
||||
}
|
||||
|
||||
@@ -1467,10 +1429,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::UpdateAllMoviesPrompt.into());
|
||||
|
||||
LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.confirm.key,
|
||||
DEFAULT_KEYBINDINGS.confirm.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::UpdateAllMoviesPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::UpdateAllMoviesPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1479,7 +1441,7 @@ mod tests {
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
Some(RadarrEvent::UpdateAllMovies)
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1744,9 +1706,9 @@ mod tests {
|
||||
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if library_handler_blocks.contains(&active_radarr_block) {
|
||||
assert!(LibraryHandler::accepts(&active_radarr_block));
|
||||
assert!(LibraryHandler::accepts(active_radarr_block));
|
||||
} else {
|
||||
assert!(!LibraryHandler::accepts(&active_radarr_block));
|
||||
assert!(!LibraryHandler::accepts(active_radarr_block));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1757,10 +1719,10 @@ mod tests {
|
||||
app.is_loading = true;
|
||||
|
||||
let handler = LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -1772,10 +1734,10 @@ mod tests {
|
||||
app.is_loading = false;
|
||||
|
||||
let handler = LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -1792,10 +1754,10 @@ mod tests {
|
||||
.set_items(vec![Movie::default()]);
|
||||
|
||||
let handler = LibraryHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Movies,
|
||||
&None,
|
||||
ActiveRadarrBlock::Movies,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
|
||||
@@ -27,10 +27,10 @@ mod movie_details_handler;
|
||||
mod library_handler_tests;
|
||||
|
||||
pub(super) struct LibraryHandler<'a, 'b> {
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_radarr_block: &'a ActiveRadarrBlock,
|
||||
context: &'a Option<ActiveRadarrBlock>,
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, 'b> {
|
||||
@@ -54,19 +54,19 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
|
||||
}
|
||||
}
|
||||
|
||||
fn accepts(active_block: &'a ActiveRadarrBlock) -> bool {
|
||||
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
||||
AddMovieHandler::accepts(active_block)
|
||||
|| DeleteMovieHandler::accepts(active_block)
|
||||
|| EditMovieHandler::accepts(active_block)
|
||||
|| MovieDetailsHandler::accepts(active_block)
|
||||
|| LIBRARY_BLOCKS.contains(active_block)
|
||||
|| LIBRARY_BLOCKS.contains(&active_block)
|
||||
}
|
||||
|
||||
fn with(
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_block: &'a ActiveRadarrBlock,
|
||||
context: &'a Option<ActiveRadarrBlock>,
|
||||
active_block: ActiveRadarrBlock,
|
||||
context: Option<ActiveRadarrBlock>,
|
||||
) -> LibraryHandler<'a, 'b> {
|
||||
LibraryHandler {
|
||||
key,
|
||||
@@ -76,7 +76,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
|
||||
}
|
||||
}
|
||||
|
||||
fn get_key(&self) -> &Key {
|
||||
fn get_key(&self) -> Key {
|
||||
self.key
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
|
||||
}
|
||||
|
||||
fn handle_delete(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::Movies {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::Movies {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::DeleteMoviePrompt.into());
|
||||
@@ -317,14 +317,14 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
|
||||
let key = self.key;
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::Movies => match self.key {
|
||||
_ if *key == DEFAULT_KEYBINDINGS.search.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.search.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::SearchMovie.into());
|
||||
self.app.data.radarr_data.movies.search = Some(HorizontallyScrollableText::default());
|
||||
self.app.should_ignore_quit_key = true;
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.filter.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.filter.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::FilterMovies.into());
|
||||
@@ -332,7 +332,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
|
||||
self.app.data.radarr_data.movies.filter = Some(HorizontallyScrollableText::default());
|
||||
self.app.should_ignore_quit_key = true;
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.edit.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.edit.key => {
|
||||
self.app.push_navigation_stack(
|
||||
(
|
||||
ActiveRadarrBlock::EditMoviePrompt,
|
||||
@@ -344,22 +344,22 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
|
||||
self.app.data.radarr_data.selected_block =
|
||||
BlockSelectionState::new(&EDIT_MOVIE_SELECTION_BLOCKS);
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.add.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.add.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::AddMovieSearchInput.into());
|
||||
self.app.data.radarr_data.add_movie_search = Some(HorizontallyScrollableText::default());
|
||||
self.app.should_ignore_quit_key = true;
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.update.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.update.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::UpdateAllMoviesPrompt.into());
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||
self.app.should_refresh = true;
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.sort.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.sort.key => {
|
||||
self
|
||||
.app
|
||||
.data
|
||||
@@ -387,7 +387,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
|
||||
)
|
||||
}
|
||||
ActiveRadarrBlock::UpdateAllMoviesPrompt => {
|
||||
if *key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
if key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action = Some(RadarrEvent::UpdateAllMovies);
|
||||
|
||||
|
||||
@@ -18,22 +18,22 @@ use crate::network::radarr_network::RadarrEvent;
|
||||
mod movie_details_handler_tests;
|
||||
|
||||
pub(super) struct MovieDetailsHandler<'a, 'b> {
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_radarr_block: &'a ActiveRadarrBlock,
|
||||
_context: &'a Option<ActiveRadarrBlock>,
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for MovieDetailsHandler<'a, 'b> {
|
||||
fn accepts(active_block: &'a ActiveRadarrBlock) -> bool {
|
||||
MOVIE_DETAILS_BLOCKS.contains(active_block)
|
||||
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
||||
MOVIE_DETAILS_BLOCKS.contains(&active_block)
|
||||
}
|
||||
|
||||
fn with(
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_block: &'a ActiveRadarrBlock,
|
||||
_context: &'a Option<ActiveRadarrBlock>,
|
||||
active_block: ActiveRadarrBlock,
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
) -> MovieDetailsHandler<'a, 'b> {
|
||||
MovieDetailsHandler {
|
||||
key,
|
||||
@@ -43,7 +43,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for MovieDetailsHandler<
|
||||
}
|
||||
}
|
||||
|
||||
fn get_key(&self) -> &Key {
|
||||
fn get_key(&self) -> Key {
|
||||
self.key
|
||||
}
|
||||
|
||||
@@ -334,16 +334,16 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for MovieDetailsHandler<
|
||||
| ActiveRadarrBlock::Cast
|
||||
| ActiveRadarrBlock::Crew
|
||||
| ActiveRadarrBlock::ManualSearch => match self.key {
|
||||
_ if *self.key == DEFAULT_KEYBINDINGS.left.key => {
|
||||
_ if self.key == DEFAULT_KEYBINDINGS.left.key => {
|
||||
self.app.data.radarr_data.movie_info_tabs.previous();
|
||||
self.app.pop_and_push_navigation_stack(
|
||||
*self.app.data.radarr_data.movie_info_tabs.get_active_route(),
|
||||
self.app.data.radarr_data.movie_info_tabs.get_active_route(),
|
||||
);
|
||||
}
|
||||
_ if *self.key == DEFAULT_KEYBINDINGS.right.key => {
|
||||
_ if self.key == DEFAULT_KEYBINDINGS.right.key => {
|
||||
self.app.data.radarr_data.movie_info_tabs.next();
|
||||
self.app.pop_and_push_navigation_stack(
|
||||
*self.app.data.radarr_data.movie_info_tabs.get_active_route(),
|
||||
self.app.data.radarr_data.movie_info_tabs.get_active_route(),
|
||||
);
|
||||
}
|
||||
_ => (),
|
||||
@@ -425,23 +425,23 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for MovieDetailsHandler<
|
||||
|
||||
fn handle_char_key_event(&mut self) {
|
||||
let key = self.key;
|
||||
match *self.active_radarr_block {
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::MovieDetails
|
||||
| ActiveRadarrBlock::MovieHistory
|
||||
| ActiveRadarrBlock::FileInfo
|
||||
| ActiveRadarrBlock::Cast
|
||||
| ActiveRadarrBlock::Crew
|
||||
| ActiveRadarrBlock::ManualSearch => match self.key {
|
||||
_ if *key == DEFAULT_KEYBINDINGS.search.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.search.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::AutomaticallySearchMoviePrompt.into());
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.edit.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.edit.key => {
|
||||
self.app.push_navigation_stack(
|
||||
(
|
||||
ActiveRadarrBlock::EditMoviePrompt,
|
||||
Some(*self.active_radarr_block),
|
||||
Some(self.active_radarr_block),
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
@@ -449,17 +449,17 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for MovieDetailsHandler<
|
||||
self.app.data.radarr_data.selected_block =
|
||||
BlockSelectionState::new(&EDIT_MOVIE_SELECTION_BLOCKS);
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.update.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.update.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::UpdateAndScanPrompt.into());
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||
self
|
||||
.app
|
||||
.pop_and_push_navigation_stack((*self.active_radarr_block).into());
|
||||
.pop_and_push_navigation_stack((self.active_radarr_block).into());
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.sort.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.sort.key => {
|
||||
self
|
||||
.app
|
||||
.data
|
||||
@@ -476,7 +476,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for MovieDetailsHandler<
|
||||
_ => (),
|
||||
},
|
||||
ActiveRadarrBlock::AutomaticallySearchMoviePrompt => {
|
||||
if *key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
if key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action =
|
||||
Some(RadarrEvent::TriggerAutomaticSearch(None));
|
||||
@@ -485,7 +485,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for MovieDetailsHandler<
|
||||
}
|
||||
}
|
||||
ActiveRadarrBlock::UpdateAndScanPrompt => {
|
||||
if *key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
if key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action = Some(RadarrEvent::UpdateAndScan(None));
|
||||
|
||||
@@ -493,7 +493,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for MovieDetailsHandler<
|
||||
}
|
||||
}
|
||||
ActiveRadarrBlock::ManualSearchConfirmPrompt => {
|
||||
if *key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
if key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action =
|
||||
Some(RadarrEvent::DownloadRelease(None));
|
||||
|
||||
@@ -40,10 +40,10 @@ mod tests {
|
||||
});
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.up.key,
|
||||
DEFAULT_KEYBINDINGS.up.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::MovieDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -60,10 +60,10 @@ mod tests {
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.down.key,
|
||||
DEFAULT_KEYBINDINGS.down.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::MovieDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -90,10 +90,10 @@ mod tests {
|
||||
});
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.up.key,
|
||||
DEFAULT_KEYBINDINGS.up.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::MovieDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -110,10 +110,10 @@ mod tests {
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.down.key,
|
||||
DEFAULT_KEYBINDINGS.down.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::MovieDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -145,7 +145,7 @@ mod tests {
|
||||
));
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::MovieHistory, &None).handle();
|
||||
MovieDetailsHandler::with(key, &mut app, ActiveRadarrBlock::MovieHistory, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -161,7 +161,7 @@ mod tests {
|
||||
"Test 2"
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::MovieHistory, &None).handle();
|
||||
MovieDetailsHandler::with(key, &mut app, ActiveRadarrBlock::MovieHistory, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -194,7 +194,7 @@ mod tests {
|
||||
));
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::MovieHistory, &None).handle();
|
||||
MovieDetailsHandler::with(key, &mut app, ActiveRadarrBlock::MovieHistory, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -210,7 +210,7 @@ mod tests {
|
||||
"Test 1"
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::MovieHistory, &None).handle();
|
||||
MovieDetailsHandler::with(key, &mut app, ActiveRadarrBlock::MovieHistory, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -238,7 +238,7 @@ mod tests {
|
||||
.set_items(simple_stateful_iterable_vec!(Credit, String, person_name));
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::Cast, &None).handle();
|
||||
MovieDetailsHandler::with(key, &mut app, ActiveRadarrBlock::Cast, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -253,7 +253,7 @@ mod tests {
|
||||
"Test 2"
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::Cast, &None).handle();
|
||||
MovieDetailsHandler::with(key, &mut app, ActiveRadarrBlock::Cast, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -281,7 +281,7 @@ mod tests {
|
||||
.set_items(simple_stateful_iterable_vec!(Credit, String, person_name));
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::Cast, &None).handle();
|
||||
MovieDetailsHandler::with(key, &mut app, ActiveRadarrBlock::Cast, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -296,7 +296,7 @@ mod tests {
|
||||
"Test 1"
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::Cast, &None).handle();
|
||||
MovieDetailsHandler::with(key, &mut app, ActiveRadarrBlock::Cast, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -323,7 +323,7 @@ mod tests {
|
||||
.set_items(simple_stateful_iterable_vec!(Credit, String, person_name));
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::Crew, &None).handle();
|
||||
MovieDetailsHandler::with(key, &mut app, ActiveRadarrBlock::Crew, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -338,7 +338,7 @@ mod tests {
|
||||
"Test 2"
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::Crew, &None).handle();
|
||||
MovieDetailsHandler::with(key, &mut app, ActiveRadarrBlock::Crew, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -366,7 +366,7 @@ mod tests {
|
||||
.set_items(simple_stateful_iterable_vec!(Credit, String, person_name));
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::Crew, &None).handle();
|
||||
MovieDetailsHandler::with(key, &mut app, ActiveRadarrBlock::Crew, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -381,7 +381,7 @@ mod tests {
|
||||
"Test 1"
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::Crew, &None).handle();
|
||||
MovieDetailsHandler::with(key, &mut app, ActiveRadarrBlock::Crew, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -411,7 +411,7 @@ mod tests {
|
||||
));
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::ManualSearch, &None).handle();
|
||||
MovieDetailsHandler::with(key, &mut app, ActiveRadarrBlock::ManualSearch, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -427,7 +427,7 @@ mod tests {
|
||||
"Test 2"
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::ManualSearch, &None).handle();
|
||||
MovieDetailsHandler::with(key, &mut app, ActiveRadarrBlock::ManualSearch, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -459,7 +459,7 @@ mod tests {
|
||||
));
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::ManualSearch, &None).handle();
|
||||
MovieDetailsHandler::with(key, &mut app, ActiveRadarrBlock::ManualSearch, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -475,7 +475,7 @@ mod tests {
|
||||
"Test 1"
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::ManualSearch, &None).handle();
|
||||
MovieDetailsHandler::with(key, &mut app, ActiveRadarrBlock::ManualSearch, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app
|
||||
@@ -505,10 +505,10 @@ mod tests {
|
||||
if key == Key::Up {
|
||||
for i in (0..release_field_vec.len()).rev() {
|
||||
MovieDetailsHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::ManualSearchSortPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::ManualSearchSortPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -530,10 +530,10 @@ mod tests {
|
||||
} else {
|
||||
for i in 0..release_field_vec.len() {
|
||||
MovieDetailsHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::ManualSearchSortPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::ManualSearchSortPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -572,10 +572,10 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::MovieDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -592,10 +592,10 @@ mod tests {
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::MovieDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -623,10 +623,10 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::MovieDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -643,10 +643,10 @@ mod tests {
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::MovieDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -677,10 +677,10 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieHistory,
|
||||
&None,
|
||||
ActiveRadarrBlock::MovieHistory,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -699,10 +699,10 @@ mod tests {
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieHistory,
|
||||
&None,
|
||||
ActiveRadarrBlock::MovieHistory,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -736,10 +736,10 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieHistory,
|
||||
&None,
|
||||
ActiveRadarrBlock::MovieHistory,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -758,10 +758,10 @@ mod tests {
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieHistory,
|
||||
&None,
|
||||
ActiveRadarrBlock::MovieHistory,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -790,10 +790,10 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Cast,
|
||||
&None,
|
||||
ActiveRadarrBlock::Cast,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -811,10 +811,10 @@ mod tests {
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Cast,
|
||||
&None,
|
||||
ActiveRadarrBlock::Cast,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -843,10 +843,10 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Cast,
|
||||
&None,
|
||||
ActiveRadarrBlock::Cast,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -864,10 +864,10 @@ mod tests {
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Cast,
|
||||
&None,
|
||||
ActiveRadarrBlock::Cast,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -895,10 +895,10 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Crew,
|
||||
&None,
|
||||
ActiveRadarrBlock::Crew,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -916,10 +916,10 @@ mod tests {
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Crew,
|
||||
&None,
|
||||
ActiveRadarrBlock::Crew,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -948,10 +948,10 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Crew,
|
||||
&None,
|
||||
ActiveRadarrBlock::Crew,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -969,10 +969,10 @@ mod tests {
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Crew,
|
||||
&None,
|
||||
ActiveRadarrBlock::Crew,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1003,10 +1003,10 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::ManualSearch,
|
||||
&None,
|
||||
ActiveRadarrBlock::ManualSearch,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1025,10 +1025,10 @@ mod tests {
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::ManualSearch,
|
||||
&None,
|
||||
ActiveRadarrBlock::ManualSearch,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1061,10 +1061,10 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::ManualSearch,
|
||||
&None,
|
||||
ActiveRadarrBlock::ManualSearch,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1083,10 +1083,10 @@ mod tests {
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::ManualSearch,
|
||||
&None,
|
||||
ActiveRadarrBlock::ManualSearch,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1114,10 +1114,10 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(movie_details_modal);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::ManualSearchSortPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::ManualSearchSortPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1137,10 +1137,10 @@ mod tests {
|
||||
);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::ManualSearchSortPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::ManualSearchSortPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -1179,11 +1179,11 @@ mod tests {
|
||||
) {
|
||||
let mut app = App::default();
|
||||
|
||||
MovieDetailsHandler::with(&key, &mut app, &active_radarr_block, &None).handle();
|
||||
MovieDetailsHandler::with(key, &mut app, active_radarr_block, None).handle();
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
MovieDetailsHandler::with(&key, &mut app, &active_radarr_block, &None).handle();
|
||||
MovieDetailsHandler::with(key, &mut app, active_radarr_block, None).handle();
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
@@ -1212,23 +1212,21 @@ mod tests {
|
||||
.position(|tab_route| tab_route.route == right_block.into())
|
||||
.unwrap_or_default();
|
||||
|
||||
MovieDetailsHandler::with(&DEFAULT_KEYBINDINGS.left.key, &mut app, &right_block, &None)
|
||||
.handle();
|
||||
MovieDetailsHandler::with(DEFAULT_KEYBINDINGS.left.key, &mut app, right_block, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
app.data.radarr_data.movie_info_tabs.get_active_route()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &left_block.into());
|
||||
assert_eq!(app.get_current_route(), left_block.into());
|
||||
|
||||
MovieDetailsHandler::with(&DEFAULT_KEYBINDINGS.right.key, &mut app, &left_block, &None)
|
||||
.handle();
|
||||
MovieDetailsHandler::with(DEFAULT_KEYBINDINGS.right.key, &mut app, left_block, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
app.data.radarr_data.movie_info_tabs.get_active_route()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &right_block.into());
|
||||
assert_eq!(app.get_current_route(), right_block.into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1256,17 +1254,12 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(modal);
|
||||
app.push_navigation_stack(ActiveRadarrBlock::ManualSearch.into());
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::ManualSearch,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
MovieDetailsHandler::with(SUBMIT_KEY, &mut app, ActiveRadarrBlock::ManualSearch, None)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::ManualSearchConfirmPrompt.into()
|
||||
ActiveRadarrBlock::ManualSearchConfirmPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1280,17 +1273,12 @@ mod tests {
|
||||
});
|
||||
app.push_navigation_stack(ActiveRadarrBlock::ManualSearch.into());
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::ManualSearch,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
MovieDetailsHandler::with(SUBMIT_KEY, &mut app, ActiveRadarrBlock::ManualSearch, None)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::ManualSearch.into()
|
||||
ActiveRadarrBlock::ManualSearch.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1320,12 +1308,12 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::MovieDetails.into());
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
|
||||
MovieDetailsHandler::with(&SUBMIT_KEY, &mut app, &prompt_block, &None).handle();
|
||||
MovieDetailsHandler::with(SUBMIT_KEY, &mut app, prompt_block, None).handle();
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::MovieDetails.into()
|
||||
ActiveRadarrBlock::MovieDetails.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
@@ -1350,12 +1338,12 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::MovieDetails.into());
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
|
||||
MovieDetailsHandler::with(&SUBMIT_KEY, &mut app, &prompt_block, &None).handle();
|
||||
MovieDetailsHandler::with(SUBMIT_KEY, &mut app, prompt_block, None).handle();
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::MovieDetails.into()
|
||||
ActiveRadarrBlock::MovieDetails.into()
|
||||
);
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
}
|
||||
@@ -1375,16 +1363,16 @@ mod tests {
|
||||
expected_vec.reverse();
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::ManualSearchSortPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::ManualSearchSortPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::ManualSearch.into()
|
||||
ActiveRadarrBlock::ManualSearch.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app
|
||||
@@ -1430,9 +1418,9 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Movies.into());
|
||||
app.push_navigation_stack(active_radarr_block.into());
|
||||
|
||||
MovieDetailsHandler::with(&ESC_KEY, &mut app, &active_radarr_block, &None).handle();
|
||||
MovieDetailsHandler::with(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_movie_info_tabs_reset!(app.data.radarr_data);
|
||||
}
|
||||
|
||||
@@ -1453,10 +1441,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::Movies.into());
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
|
||||
MovieDetailsHandler::with(&ESC_KEY, &mut app, &prompt_block, &None).handle();
|
||||
MovieDetailsHandler::with(ESC_KEY, &mut app, prompt_block, None).handle();
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1508,16 +1496,16 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(modal);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.search.key,
|
||||
DEFAULT_KEYBINDINGS.search.key,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&None,
|
||||
active_radarr_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AutomaticallySearchMoviePrompt.into()
|
||||
ActiveRadarrBlock::AutomaticallySearchMoviePrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1542,14 +1530,14 @@ mod tests {
|
||||
});
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.search.key,
|
||||
DEFAULT_KEYBINDINGS.search.key,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&None,
|
||||
active_radarr_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &active_radarr_block.into());
|
||||
assert_eq!(app.get_current_route(), active_radarr_block.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1560,16 +1548,16 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(modal);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.sort.key,
|
||||
DEFAULT_KEYBINDINGS.sort.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::ManualSearch,
|
||||
&None,
|
||||
ActiveRadarrBlock::ManualSearch,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::ManualSearchSortPrompt.into()
|
||||
ActiveRadarrBlock::ManualSearchSortPrompt.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app
|
||||
@@ -1608,16 +1596,16 @@ mod tests {
|
||||
});
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.sort.key,
|
||||
DEFAULT_KEYBINDINGS.sort.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::ManualSearch,
|
||||
&None,
|
||||
ActiveRadarrBlock::ManualSearch,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::ManualSearch.into()
|
||||
ActiveRadarrBlock::ManualSearch.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1661,14 +1649,14 @@ mod tests {
|
||||
});
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.edit.key,
|
||||
DEFAULT_KEYBINDINGS.edit.key,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&None,
|
||||
active_radarr_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &active_radarr_block.into());
|
||||
assert_eq!(app.get_current_route(), active_radarr_block.into());
|
||||
assert!(app.data.radarr_data.edit_movie_modal.is_none());
|
||||
}
|
||||
|
||||
@@ -1700,16 +1688,16 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(modal);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.update.key,
|
||||
DEFAULT_KEYBINDINGS.update.key,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&None,
|
||||
active_radarr_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::UpdateAndScanPrompt.into()
|
||||
ActiveRadarrBlock::UpdateAndScanPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1734,14 +1722,14 @@ mod tests {
|
||||
});
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.update.key,
|
||||
DEFAULT_KEYBINDINGS.update.key,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&None,
|
||||
active_radarr_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &active_radarr_block.into());
|
||||
assert_eq!(app.get_current_route(), active_radarr_block.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -1772,14 +1760,14 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(modal);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.refresh.key,
|
||||
DEFAULT_KEYBINDINGS.refresh.key,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&None,
|
||||
active_radarr_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &active_radarr_block.into());
|
||||
assert_eq!(app.get_current_route(), active_radarr_block.into());
|
||||
assert!(app.is_routing);
|
||||
}
|
||||
|
||||
@@ -1804,14 +1792,14 @@ mod tests {
|
||||
});
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.refresh.key,
|
||||
DEFAULT_KEYBINDINGS.refresh.key,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&None,
|
||||
active_radarr_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &active_radarr_block.into());
|
||||
assert_eq!(app.get_current_route(), active_radarr_block.into());
|
||||
assert!(app.is_routing);
|
||||
}
|
||||
|
||||
@@ -1841,17 +1829,17 @@ mod tests {
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.confirm.key,
|
||||
DEFAULT_KEYBINDINGS.confirm.key,
|
||||
&mut app,
|
||||
&prompt_block,
|
||||
&None,
|
||||
prompt_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::MovieDetails.into()
|
||||
ActiveRadarrBlock::MovieDetails.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
@@ -2025,9 +2013,9 @@ mod tests {
|
||||
fn test_movie_details_handler_accepts() {
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if MOVIE_DETAILS_BLOCKS.contains(&active_radarr_block) {
|
||||
assert!(MovieDetailsHandler::accepts(&active_radarr_block));
|
||||
assert!(MovieDetailsHandler::accepts(active_radarr_block));
|
||||
} else {
|
||||
assert!(!MovieDetailsHandler::accepts(&active_radarr_block));
|
||||
assert!(!MovieDetailsHandler::accepts(active_radarr_block));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2062,10 +2050,10 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(modal);
|
||||
|
||||
let handler = MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&movie_details_block,
|
||||
&None,
|
||||
movie_details_block,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -2078,10 +2066,10 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(MovieDetailsModal::default());
|
||||
|
||||
let handler = MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::MovieDetails,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -2097,10 +2085,10 @@ mod tests {
|
||||
});
|
||||
|
||||
let handler = MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieDetails,
|
||||
&None,
|
||||
ActiveRadarrBlock::MovieDetails,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
@@ -2117,10 +2105,10 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(modal);
|
||||
|
||||
let handler = MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieHistory,
|
||||
&None,
|
||||
ActiveRadarrBlock::MovieHistory,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
@@ -2135,10 +2123,10 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(modal);
|
||||
|
||||
let handler = MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Cast,
|
||||
&None,
|
||||
ActiveRadarrBlock::Cast,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
@@ -2153,10 +2141,10 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(modal);
|
||||
|
||||
let handler = MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::Crew,
|
||||
&None,
|
||||
ActiveRadarrBlock::Crew,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
@@ -2173,10 +2161,10 @@ mod tests {
|
||||
app.data.radarr_data.movie_details_modal = Some(modal);
|
||||
|
||||
let handler = MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::ManualSearch,
|
||||
&None,
|
||||
ActiveRadarrBlock::ManualSearch,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
|
||||
@@ -27,10 +27,10 @@ mod radarr_handler_tests;
|
||||
mod radarr_handler_test_utils;
|
||||
|
||||
pub(super) struct RadarrHandler<'a, 'b> {
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_radarr_block: &'a ActiveRadarrBlock,
|
||||
context: &'a Option<ActiveRadarrBlock>,
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RadarrHandler<'a, 'b> {
|
||||
@@ -63,15 +63,15 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RadarrHandler<'a, 'b
|
||||
}
|
||||
}
|
||||
|
||||
fn accepts(_active_block: &'a ActiveRadarrBlock) -> bool {
|
||||
fn accepts(_active_block: ActiveRadarrBlock) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn with(
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_block: &'a ActiveRadarrBlock,
|
||||
context: &'a Option<ActiveRadarrBlock>,
|
||||
active_block: ActiveRadarrBlock,
|
||||
context: Option<ActiveRadarrBlock>,
|
||||
) -> RadarrHandler<'a, 'b> {
|
||||
RadarrHandler {
|
||||
key,
|
||||
@@ -81,7 +81,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RadarrHandler<'a, 'b
|
||||
}
|
||||
}
|
||||
|
||||
fn get_key(&self) -> &Key {
|
||||
fn get_key(&self) -> Key {
|
||||
self.key
|
||||
}
|
||||
|
||||
@@ -108,16 +108,16 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RadarrHandler<'a, 'b
|
||||
fn handle_char_key_event(&mut self) {}
|
||||
}
|
||||
|
||||
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;
|
||||
match key_ref {
|
||||
_ if *key == DEFAULT_KEYBINDINGS.left.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.left.key => {
|
||||
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 *key == DEFAULT_KEYBINDINGS.right.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.right.key => {
|
||||
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());
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
||||
@@ -23,15 +23,15 @@ mod utils {
|
||||
}]);
|
||||
app.data.radarr_data = radarr_data;
|
||||
|
||||
$handler::with(&DEFAULT_KEYBINDINGS.edit.key, &mut app, &$block, &None).handle();
|
||||
$handler::with(DEFAULT_KEYBINDINGS.edit.key, &mut app, $block, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&(ActiveRadarrBlock::EditMoviePrompt, Some($context)).into()
|
||||
(ActiveRadarrBlock::EditMoviePrompt, Some($context)).into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::EditMovieToggleMonitored
|
||||
ActiveRadarrBlock::EditMovieToggleMonitored
|
||||
);
|
||||
assert_eq!(
|
||||
app
|
||||
@@ -137,15 +137,15 @@ mod utils {
|
||||
}]);
|
||||
app.data.radarr_data = radarr_data;
|
||||
|
||||
$handler::with(&DEFAULT_KEYBINDINGS.edit.key, &mut app, &$block, &None).handle();
|
||||
$handler::with(DEFAULT_KEYBINDINGS.edit.key, &mut app, $block, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&(ActiveRadarrBlock::EditCollectionPrompt, Some($context)).into()
|
||||
(ActiveRadarrBlock::EditCollectionPrompt, Some($context)).into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.get_active_block(),
|
||||
&ActiveRadarrBlock::EditCollectionToggleMonitored
|
||||
ActiveRadarrBlock::EditCollectionToggleMonitored
|
||||
);
|
||||
assert_eq!(
|
||||
app
|
||||
@@ -234,29 +234,29 @@ mod utils {
|
||||
($block:expr, $expected_block:expr) => {
|
||||
let mut app = App::default();
|
||||
|
||||
RadarrHandler::with(&DELETE_KEY, &mut app, &$block, &None).handle();
|
||||
RadarrHandler::with(DELETE_KEY, &mut app, $block, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &$expected_block.into());
|
||||
assert_eq!(app.get_current_route(), $expected_block.into());
|
||||
};
|
||||
|
||||
($handler:ident, $block:expr, $expected_block:expr) => {
|
||||
let mut app = App::default();
|
||||
|
||||
$handler::with(&DELETE_KEY, &mut app, &$block, &None).handle();
|
||||
$handler::with(DELETE_KEY, &mut app, $block, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &$expected_block.into());
|
||||
assert_eq!(app.get_current_route(), $expected_block.into());
|
||||
};
|
||||
|
||||
($app:expr, $block:expr, $expected_block:expr) => {
|
||||
RadarrHandler::with(&DELETE_KEY, &mut $app, &$block, &None).handle();
|
||||
RadarrHandler::with(DELETE_KEY, &mut $app, $block, None).handle();
|
||||
|
||||
assert_eq!($app.get_current_route(), &$expected_block.into());
|
||||
assert_eq!($app.get_current_route(), $expected_block.into());
|
||||
};
|
||||
|
||||
($handler:ident, $app:expr, $block:expr, $expected_block:expr) => {
|
||||
$handler::with(&DELETE_KEY, &mut $app, &$block, &None).handle();
|
||||
$handler::with(DELETE_KEY, &mut $app, $block, None).handle();
|
||||
|
||||
assert_eq!($app.get_current_route(), &$expected_block.into());
|
||||
assert_eq!($app.get_current_route(), $expected_block.into());
|
||||
};
|
||||
}
|
||||
|
||||
@@ -266,9 +266,9 @@ mod utils {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack($block.into());
|
||||
|
||||
$handler::with(&DEFAULT_KEYBINDINGS.refresh.key, &mut app, &$block, &None).handle();
|
||||
$handler::with(DEFAULT_KEYBINDINGS.refresh.key, &mut app, $block, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &$block.into());
|
||||
assert_eq!(app.get_current_route(), $block.into());
|
||||
assert!(app.should_refresh);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -27,23 +27,23 @@ mod tests {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data.main_tabs.set_index(index);
|
||||
|
||||
handle_change_tab_left_right_keys(&mut app, &DEFAULT_KEYBINDINGS.left.key);
|
||||
handle_change_tab_left_right_keys(&mut app, DEFAULT_KEYBINDINGS.left.key);
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.main_tabs.get_active_route(),
|
||||
&left_block.into()
|
||||
left_block.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &left_block.into());
|
||||
assert_eq!(app.get_current_route(), left_block.into());
|
||||
|
||||
app.data.radarr_data.main_tabs.set_index(index);
|
||||
|
||||
handle_change_tab_left_right_keys(&mut app, &DEFAULT_KEYBINDINGS.right.key);
|
||||
handle_change_tab_left_right_keys(&mut app, DEFAULT_KEYBINDINGS.right.key);
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.main_tabs.get_active_route(),
|
||||
&right_block.into()
|
||||
right_block.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &right_block.into());
|
||||
assert_eq!(app.get_current_route(), right_block.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -213,7 +213,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_radarr_handler_accepts() {
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
assert!(RadarrHandler::accepts(&active_radarr_block));
|
||||
assert!(RadarrHandler::accepts(active_radarr_block));
|
||||
})
|
||||
}
|
||||
|
||||
@@ -223,10 +223,10 @@ mod tests {
|
||||
app.is_loading = true;
|
||||
|
||||
let handler = RadarrHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
ActiveRadarrBlock::System,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
|
||||
@@ -13,22 +13,22 @@ use crate::{handle_text_box_keys, handle_text_box_left_right_keys};
|
||||
mod root_folders_handler_tests;
|
||||
|
||||
pub(super) struct RootFoldersHandler<'a, 'b> {
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_radarr_block: &'a ActiveRadarrBlock,
|
||||
_context: &'a Option<ActiveRadarrBlock>,
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RootFoldersHandler<'a, 'b> {
|
||||
fn accepts(active_block: &'a ActiveRadarrBlock) -> bool {
|
||||
ROOT_FOLDERS_BLOCKS.contains(active_block)
|
||||
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
||||
ROOT_FOLDERS_BLOCKS.contains(&active_block)
|
||||
}
|
||||
|
||||
fn with(
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_block: &'a ActiveRadarrBlock,
|
||||
_context: &'a Option<ActiveRadarrBlock>,
|
||||
active_block: ActiveRadarrBlock,
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
) -> RootFoldersHandler<'a, 'b> {
|
||||
RootFoldersHandler {
|
||||
key,
|
||||
@@ -38,7 +38,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RootFoldersHandler<'
|
||||
}
|
||||
}
|
||||
|
||||
fn get_key(&self) -> &Key {
|
||||
fn get_key(&self) -> Key {
|
||||
self.key
|
||||
}
|
||||
|
||||
@@ -47,13 +47,13 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RootFoldersHandler<'
|
||||
}
|
||||
|
||||
fn handle_scroll_up(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::RootFolders {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::RootFolders {
|
||||
self.app.data.radarr_data.root_folders.scroll_up()
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_scroll_down(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::RootFolders {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::RootFolders {
|
||||
self.app.data.radarr_data.root_folders.scroll_down()
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RootFoldersHandler<'
|
||||
}
|
||||
|
||||
fn handle_delete(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::RootFolders {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::RootFolders {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::DeleteRootFolderPrompt.into())
|
||||
@@ -121,7 +121,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RootFoldersHandler<'
|
||||
|
||||
self.app.pop_navigation_stack();
|
||||
}
|
||||
_ if *self.active_radarr_block == ActiveRadarrBlock::AddRootFolderPrompt
|
||||
_ if self.active_radarr_block == ActiveRadarrBlock::AddRootFolderPrompt
|
||||
&& !self
|
||||
.app
|
||||
.data
|
||||
@@ -161,10 +161,10 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RootFoldersHandler<'
|
||||
let key = self.key;
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::RootFolders => match self.key {
|
||||
_ if *key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||
self.app.should_refresh = true;
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.add.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.add.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::AddRootFolderPrompt.into());
|
||||
@@ -181,7 +181,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RootFoldersHandler<'
|
||||
)
|
||||
}
|
||||
ActiveRadarrBlock::DeleteRootFolderPrompt => {
|
||||
if *key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
if key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action =
|
||||
Some(RadarrEvent::DeleteRootFolder(None));
|
||||
|
||||
@@ -42,14 +42,14 @@ mod tests {
|
||||
.root_folders
|
||||
.set_items(simple_stateful_iterable_vec!(RootFolder, String, path));
|
||||
|
||||
RootFoldersHandler::with(&key, &mut app, &ActiveRadarrBlock::RootFolders, &None).handle();
|
||||
RootFoldersHandler::with(key, &mut app, ActiveRadarrBlock::RootFolders, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.root_folders.current_selection().path,
|
||||
"Test 1"
|
||||
);
|
||||
|
||||
RootFoldersHandler::with(&key, &mut app, &ActiveRadarrBlock::RootFolders, &None).handle();
|
||||
RootFoldersHandler::with(key, &mut app, ActiveRadarrBlock::RootFolders, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.root_folders.current_selection().path,
|
||||
@@ -89,10 +89,10 @@ mod tests {
|
||||
.set_items(extended_stateful_iterable_vec!(RootFolder, String, path));
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::RootFolders,
|
||||
&None,
|
||||
ActiveRadarrBlock::RootFolders,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -102,10 +102,10 @@ mod tests {
|
||||
);
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::RootFolders,
|
||||
&None,
|
||||
ActiveRadarrBlock::RootFolders,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -126,10 +126,10 @@ mod tests {
|
||||
app.data.radarr_data.edit_root_folder = Some("Test".into());
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -146,10 +146,10 @@ mod tests {
|
||||
);
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -183,17 +183,11 @@ mod tests {
|
||||
.root_folders
|
||||
.set_items(vec![RootFolder::default()]);
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&DELETE_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::RootFolders,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
RootFoldersHandler::with(DELETE_KEY, &mut app, ActiveRadarrBlock::RootFolders, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::DeleteRootFolderPrompt.into()
|
||||
ActiveRadarrBlock::DeleteRootFolderPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -208,17 +202,11 @@ mod tests {
|
||||
.root_folders
|
||||
.set_items(vec![RootFolder::default()]);
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&DELETE_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::RootFolders,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
RootFoldersHandler::with(DELETE_KEY, &mut app, ActiveRadarrBlock::RootFolders, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::RootFolders.into()
|
||||
ActiveRadarrBlock::RootFolders.into()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -238,21 +226,18 @@ mod tests {
|
||||
app.data.radarr_data.main_tabs.set_index(4);
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::RootFolders,
|
||||
&None,
|
||||
ActiveRadarrBlock::RootFolders,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.main_tabs.get_active_route(),
|
||||
&ActiveRadarrBlock::Blocklist.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::Blocklist.into()
|
||||
ActiveRadarrBlock::Blocklist.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Blocklist.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -262,18 +247,18 @@ mod tests {
|
||||
app.data.radarr_data.main_tabs.set_index(4);
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::RootFolders,
|
||||
&None,
|
||||
ActiveRadarrBlock::RootFolders,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.main_tabs.get_active_route(),
|
||||
&ActiveRadarrBlock::Indexers.into()
|
||||
ActiveRadarrBlock::Indexers.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -283,20 +268,20 @@ mod tests {
|
||||
let mut app = App::default();
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteRootFolderPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteRootFolderPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteRootFolderPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteRootFolderPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -309,10 +294,10 @@ mod tests {
|
||||
app.data.radarr_data.edit_root_folder = Some("Test".into());
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -329,10 +314,10 @@ mod tests {
|
||||
);
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -374,10 +359,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::AddRootFolderPrompt.into());
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -389,7 +374,7 @@ mod tests {
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::RootFolders.into()
|
||||
ActiveRadarrBlock::RootFolders.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -403,10 +388,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::AddRootFolderPrompt.into());
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -415,7 +400,7 @@ mod tests {
|
||||
assert!(app.data.radarr_data.prompt_confirm_action.is_none());
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddRootFolderPrompt.into()
|
||||
ActiveRadarrBlock::AddRootFolderPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -432,10 +417,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::DeleteRootFolderPrompt.into());
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteRootFolderPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteRootFolderPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -446,7 +431,7 @@ mod tests {
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::RootFolders.into()
|
||||
ActiveRadarrBlock::RootFolders.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -462,10 +447,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::DeleteRootFolderPrompt.into());
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteRootFolderPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteRootFolderPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -473,7 +458,7 @@ mod tests {
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::RootFolders.into()
|
||||
ActiveRadarrBlock::RootFolders.into()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -493,16 +478,16 @@ mod tests {
|
||||
app.data.radarr_data.prompt_confirm = true;
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteRootFolderPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteRootFolderPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::RootFolders.into()
|
||||
ActiveRadarrBlock::RootFolders.into()
|
||||
);
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
@@ -516,16 +501,16 @@ mod tests {
|
||||
app.should_ignore_quit_key = true;
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::RootFolders.into()
|
||||
ActiveRadarrBlock::RootFolders.into()
|
||||
);
|
||||
|
||||
assert!(app.data.radarr_data.edit_root_folder.is_none());
|
||||
@@ -541,11 +526,11 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::RootFolders.into());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::RootFolders.into());
|
||||
|
||||
RootFoldersHandler::with(&ESC_KEY, &mut app, &ActiveRadarrBlock::RootFolders, &None).handle();
|
||||
RootFoldersHandler::with(ESC_KEY, &mut app, ActiveRadarrBlock::RootFolders, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::RootFolders.into()
|
||||
ActiveRadarrBlock::RootFolders.into()
|
||||
);
|
||||
assert!(app.error.text.is_empty());
|
||||
}
|
||||
@@ -568,16 +553,16 @@ mod tests {
|
||||
.set_items(vec![RootFolder::default()]);
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.add.key,
|
||||
DEFAULT_KEYBINDINGS.add.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::RootFolders,
|
||||
&None,
|
||||
ActiveRadarrBlock::RootFolders,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::AddRootFolderPrompt.into()
|
||||
ActiveRadarrBlock::AddRootFolderPrompt.into()
|
||||
);
|
||||
assert!(app.should_ignore_quit_key);
|
||||
assert!(app.data.radarr_data.edit_root_folder.is_some());
|
||||
@@ -595,16 +580,16 @@ mod tests {
|
||||
.set_items(vec![RootFolder::default()]);
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.add.key,
|
||||
DEFAULT_KEYBINDINGS.add.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::RootFolders,
|
||||
&None,
|
||||
ActiveRadarrBlock::RootFolders,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::RootFolders.into()
|
||||
ActiveRadarrBlock::RootFolders.into()
|
||||
);
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
assert!(app.data.radarr_data.edit_root_folder.is_none());
|
||||
@@ -621,16 +606,16 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::RootFolders.into());
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.refresh.key,
|
||||
DEFAULT_KEYBINDINGS.refresh.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::RootFolders,
|
||||
&None,
|
||||
ActiveRadarrBlock::RootFolders,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::RootFolders.into()
|
||||
ActiveRadarrBlock::RootFolders.into()
|
||||
);
|
||||
assert!(app.should_refresh);
|
||||
}
|
||||
@@ -647,16 +632,16 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::RootFolders.into());
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.refresh.key,
|
||||
DEFAULT_KEYBINDINGS.refresh.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::RootFolders,
|
||||
&None,
|
||||
ActiveRadarrBlock::RootFolders,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::RootFolders.into()
|
||||
ActiveRadarrBlock::RootFolders.into()
|
||||
);
|
||||
assert!(!app.should_refresh);
|
||||
}
|
||||
@@ -672,10 +657,10 @@ mod tests {
|
||||
app.data.radarr_data.edit_root_folder = Some("/nfs/test".into());
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.backspace.key,
|
||||
DEFAULT_KEYBINDINGS.backspace.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -696,10 +681,10 @@ mod tests {
|
||||
app.data.radarr_data.edit_root_folder = Some(HorizontallyScrollableText::default());
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&Key::Char('h'),
|
||||
Key::Char('h'),
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::AddRootFolderPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -721,10 +706,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::DeleteRootFolderPrompt.into());
|
||||
|
||||
RootFoldersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.confirm.key,
|
||||
DEFAULT_KEYBINDINGS.confirm.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::DeleteRootFolderPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::DeleteRootFolderPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -735,7 +720,7 @@ mod tests {
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::RootFolders.into()
|
||||
ActiveRadarrBlock::RootFolders.into()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -744,9 +729,9 @@ mod tests {
|
||||
fn test_root_folders_handler_accepts() {
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if ROOT_FOLDERS_BLOCKS.contains(&active_radarr_block) {
|
||||
assert!(RootFoldersHandler::accepts(&active_radarr_block));
|
||||
assert!(RootFoldersHandler::accepts(active_radarr_block));
|
||||
} else {
|
||||
assert!(!RootFoldersHandler::accepts(&active_radarr_block));
|
||||
assert!(!RootFoldersHandler::accepts(active_radarr_block));
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -757,10 +742,10 @@ mod tests {
|
||||
app.is_loading = true;
|
||||
|
||||
let handler = RootFoldersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::RootFolders,
|
||||
&None,
|
||||
ActiveRadarrBlock::RootFolders,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -772,10 +757,10 @@ mod tests {
|
||||
app.is_loading = false;
|
||||
|
||||
let handler = RootFoldersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::RootFolders,
|
||||
&None,
|
||||
ActiveRadarrBlock::RootFolders,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -792,10 +777,10 @@ mod tests {
|
||||
.root_folders
|
||||
.set_items(vec![RootFolder::default()]);
|
||||
let handler = RootFoldersHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::RootFolders,
|
||||
&None,
|
||||
ActiveRadarrBlock::RootFolders,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
|
||||
@@ -14,10 +14,10 @@ mod system_details_handler;
|
||||
mod system_handler_tests;
|
||||
|
||||
pub(super) struct SystemHandler<'a, 'b> {
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_radarr_block: &'a ActiveRadarrBlock,
|
||||
context: &'a Option<ActiveRadarrBlock>,
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemHandler<'a, 'b> {
|
||||
@@ -31,15 +31,15 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemHandler<'a, 'b
|
||||
}
|
||||
}
|
||||
|
||||
fn accepts(active_block: &'a ActiveRadarrBlock) -> bool {
|
||||
SystemDetailsHandler::accepts(active_block) || active_block == &ActiveRadarrBlock::System
|
||||
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
||||
SystemDetailsHandler::accepts(active_block) || active_block == ActiveRadarrBlock::System
|
||||
}
|
||||
|
||||
fn with(
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_block: &'a ActiveRadarrBlock,
|
||||
context: &'a Option<ActiveRadarrBlock>,
|
||||
active_block: ActiveRadarrBlock,
|
||||
context: Option<ActiveRadarrBlock>,
|
||||
) -> SystemHandler<'a, 'b> {
|
||||
SystemHandler {
|
||||
key,
|
||||
@@ -49,7 +49,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemHandler<'a, 'b
|
||||
}
|
||||
}
|
||||
|
||||
fn get_key(&self) -> &Key {
|
||||
fn get_key(&self) -> Key {
|
||||
self.key
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemHandler<'a, 'b
|
||||
fn handle_delete(&mut self) {}
|
||||
|
||||
fn handle_left_right_action(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::System {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::System {
|
||||
handle_change_tab_left_right_keys(self.app, self.key);
|
||||
}
|
||||
}
|
||||
@@ -83,18 +83,18 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemHandler<'a, 'b
|
||||
}
|
||||
|
||||
fn handle_char_key_event(&mut self) {
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::System {
|
||||
if self.active_radarr_block == ActiveRadarrBlock::System {
|
||||
let key = self.key;
|
||||
match self.key {
|
||||
_ if *key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||
self.app.should_refresh = true;
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.events.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.events.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::SystemQueuedEvents.into());
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.logs.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.logs.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::SystemLogs.into());
|
||||
@@ -106,12 +106,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemHandler<'a, 'b
|
||||
.set_items(self.app.data.radarr_data.logs.items.to_vec());
|
||||
self.app.data.radarr_data.log_details.scroll_to_bottom();
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.tasks.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.tasks.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::SystemTasks.into());
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.update.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.update.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::SystemUpdates.into());
|
||||
|
||||
@@ -12,22 +12,22 @@ use crate::network::radarr_network::RadarrEvent;
|
||||
mod system_details_handler_tests;
|
||||
|
||||
pub(super) struct SystemDetailsHandler<'a, 'b> {
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_radarr_block: &'a ActiveRadarrBlock,
|
||||
_context: &'a Option<ActiveRadarrBlock>,
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemDetailsHandler<'a, 'b> {
|
||||
fn accepts(active_block: &'a ActiveRadarrBlock) -> bool {
|
||||
SYSTEM_DETAILS_BLOCKS.contains(active_block)
|
||||
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
||||
SYSTEM_DETAILS_BLOCKS.contains(&active_block)
|
||||
}
|
||||
|
||||
fn with(
|
||||
key: &'a Key,
|
||||
key: Key,
|
||||
app: &'a mut App<'b>,
|
||||
active_block: &'a ActiveRadarrBlock,
|
||||
context: &'a Option<ActiveRadarrBlock>,
|
||||
active_block: ActiveRadarrBlock,
|
||||
context: Option<ActiveRadarrBlock>,
|
||||
) -> SystemDetailsHandler<'a, 'b> {
|
||||
SystemDetailsHandler {
|
||||
key,
|
||||
@@ -37,7 +37,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemDetailsHandler
|
||||
}
|
||||
}
|
||||
|
||||
fn get_key(&self) -> &Key {
|
||||
fn get_key(&self) -> Key {
|
||||
self.key
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemDetailsHandler
|
||||
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::SystemLogs => match self.key {
|
||||
_ if *key == DEFAULT_KEYBINDINGS.left.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.left.key => {
|
||||
self
|
||||
.app
|
||||
.data
|
||||
@@ -110,7 +110,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemDetailsHandler
|
||||
.iter()
|
||||
.for_each(|log| log.scroll_right());
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.right.key => {
|
||||
_ if key == DEFAULT_KEYBINDINGS.right.key => {
|
||||
self
|
||||
.app
|
||||
.data
|
||||
@@ -163,14 +163,14 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemDetailsHandler
|
||||
}
|
||||
|
||||
fn handle_char_key_event(&mut self) {
|
||||
if SYSTEM_DETAILS_BLOCKS.contains(self.active_radarr_block)
|
||||
&& self.key == &DEFAULT_KEYBINDINGS.refresh.key
|
||||
if SYSTEM_DETAILS_BLOCKS.contains(&self.active_radarr_block)
|
||||
&& self.key == DEFAULT_KEYBINDINGS.refresh.key
|
||||
{
|
||||
self.app.should_refresh = true;
|
||||
}
|
||||
|
||||
if self.active_radarr_block == &ActiveRadarrBlock::SystemTaskStartConfirmPrompt
|
||||
&& *self.key == DEFAULT_KEYBINDINGS.confirm.key
|
||||
if self.active_radarr_block == ActiveRadarrBlock::SystemTaskStartConfirmPrompt
|
||||
&& self.key == DEFAULT_KEYBINDINGS.confirm.key
|
||||
{
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action = Some(RadarrEvent::StartTask(None));
|
||||
|
||||
@@ -49,14 +49,14 @@ mod tests {
|
||||
text
|
||||
));
|
||||
|
||||
SystemDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::SystemLogs, &None).handle();
|
||||
SystemDetailsHandler::with(key, &mut app, ActiveRadarrBlock::SystemLogs, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.log_details.current_selection().text,
|
||||
"Test 1"
|
||||
);
|
||||
|
||||
SystemDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::SystemLogs, &None).handle();
|
||||
SystemDetailsHandler::with(key, &mut app, ActiveRadarrBlock::SystemLogs, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.log_details.current_selection().text,
|
||||
@@ -76,14 +76,14 @@ mod tests {
|
||||
.tasks
|
||||
.set_items(simple_stateful_iterable_vec!(RadarrTask, String, name));
|
||||
|
||||
SystemDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::SystemTasks, &None).handle();
|
||||
SystemDetailsHandler::with(key, &mut app, ActiveRadarrBlock::SystemTasks, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.tasks.current_selection().name,
|
||||
"Test 2"
|
||||
);
|
||||
|
||||
SystemDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::SystemTasks, &None).handle();
|
||||
SystemDetailsHandler::with(key, &mut app, ActiveRadarrBlock::SystemTasks, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.tasks.current_selection().name,
|
||||
@@ -104,14 +104,14 @@ mod tests {
|
||||
.tasks
|
||||
.set_items(simple_stateful_iterable_vec!(RadarrTask, String, name));
|
||||
|
||||
SystemDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::SystemTasks, &None).handle();
|
||||
SystemDetailsHandler::with(key, &mut app, ActiveRadarrBlock::SystemTasks, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.tasks.current_selection().name,
|
||||
"Test 1"
|
||||
);
|
||||
|
||||
SystemDetailsHandler::with(&key, &mut app, &ActiveRadarrBlock::SystemTasks, &None).handle();
|
||||
SystemDetailsHandler::with(key, &mut app, ActiveRadarrBlock::SystemTasks, None).handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.tasks.current_selection().name,
|
||||
@@ -131,26 +131,16 @@ mod tests {
|
||||
.queued_events
|
||||
.set_items(simple_stateful_iterable_vec!(QueueEvent, String, name));
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemQueuedEvents,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
SystemDetailsHandler::with(key, &mut app, ActiveRadarrBlock::SystemQueuedEvents, None)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.queued_events.current_selection().name,
|
||||
"Test 2"
|
||||
);
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemQueuedEvents,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
SystemDetailsHandler::with(key, &mut app, ActiveRadarrBlock::SystemQueuedEvents, None)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.queued_events.current_selection().name,
|
||||
@@ -171,26 +161,16 @@ mod tests {
|
||||
.queued_events
|
||||
.set_items(simple_stateful_iterable_vec!(QueueEvent, String, name));
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemQueuedEvents,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
SystemDetailsHandler::with(key, &mut app, ActiveRadarrBlock::SystemQueuedEvents, None)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.queued_events.current_selection().name,
|
||||
"Test 1"
|
||||
);
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemQueuedEvents,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
SystemDetailsHandler::with(key, &mut app, ActiveRadarrBlock::SystemQueuedEvents, None)
|
||||
.handle();
|
||||
|
||||
assert_str_eq!(
|
||||
app.data.radarr_data.queued_events.current_selection().name,
|
||||
@@ -204,20 +184,20 @@ mod tests {
|
||||
app.data.radarr_data.updates = ScrollableText::with_string("Test 1\nTest 2".to_owned());
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.up.key,
|
||||
DEFAULT_KEYBINDINGS.up.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemUpdates,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemUpdates,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.data.radarr_data.updates.offset, 0);
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.down.key,
|
||||
DEFAULT_KEYBINDINGS.down.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemUpdates,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemUpdates,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -231,20 +211,20 @@ mod tests {
|
||||
app.data.radarr_data.updates = ScrollableText::with_string("Test 1\nTest 2".to_owned());
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.up.key,
|
||||
DEFAULT_KEYBINDINGS.up.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemUpdates,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemUpdates,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.data.radarr_data.updates.offset, 0);
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.down.key,
|
||||
DEFAULT_KEYBINDINGS.down.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemUpdates,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemUpdates,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -283,10 +263,10 @@ mod tests {
|
||||
));
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemLogs,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemLogs,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -296,10 +276,10 @@ mod tests {
|
||||
);
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemLogs,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemLogs,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -321,10 +301,10 @@ mod tests {
|
||||
.set_items(extended_stateful_iterable_vec!(RadarrTask, String, name));
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemTasks,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemTasks,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -334,10 +314,10 @@ mod tests {
|
||||
);
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemTasks,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemTasks,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -360,10 +340,10 @@ mod tests {
|
||||
.set_items(extended_stateful_iterable_vec!(RadarrTask, String, name));
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemTasks,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemTasks,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -373,10 +353,10 @@ mod tests {
|
||||
);
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemTasks,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemTasks,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -398,10 +378,10 @@ mod tests {
|
||||
.set_items(extended_stateful_iterable_vec!(QueueEvent, String, name));
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemQueuedEvents,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemQueuedEvents,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -411,10 +391,10 @@ mod tests {
|
||||
);
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemQueuedEvents,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemQueuedEvents,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -437,10 +417,10 @@ mod tests {
|
||||
.set_items(extended_stateful_iterable_vec!(QueueEvent, String, name));
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemQueuedEvents,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemQueuedEvents,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -450,10 +430,10 @@ mod tests {
|
||||
);
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemQueuedEvents,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemQueuedEvents,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -469,20 +449,20 @@ mod tests {
|
||||
app.data.radarr_data.updates = ScrollableText::with_string("Test 1\nTest 2".to_owned());
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemUpdates,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemUpdates,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.data.radarr_data.updates.offset, 1);
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemUpdates,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemUpdates,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -496,20 +476,20 @@ mod tests {
|
||||
app.data.radarr_data.updates = ScrollableText::with_string("Test 1\nTest 2".to_owned());
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemUpdates,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemUpdates,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.data.radarr_data.updates.offset, 0);
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemUpdates,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemUpdates,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -534,10 +514,10 @@ mod tests {
|
||||
.set_items(vec!["t1".into(), "t22".into()]);
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&None,
|
||||
active_radarr_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -545,10 +525,10 @@ mod tests {
|
||||
assert_eq!(app.data.radarr_data.log_details.items[1].to_string(), "t22");
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&None,
|
||||
active_radarr_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -556,10 +536,10 @@ mod tests {
|
||||
assert_eq!(app.data.radarr_data.log_details.items[1].to_string(), "22");
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&None,
|
||||
active_radarr_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -567,10 +547,10 @@ mod tests {
|
||||
assert_eq!(app.data.radarr_data.log_details.items[1].to_string(), "2");
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&None,
|
||||
active_radarr_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -578,10 +558,10 @@ mod tests {
|
||||
assert_eq!(app.data.radarr_data.log_details.items[1].to_string(), "");
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&None,
|
||||
active_radarr_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -589,10 +569,10 @@ mod tests {
|
||||
assert_eq!(app.data.radarr_data.log_details.items[1].to_string(), "");
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&None,
|
||||
active_radarr_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -600,10 +580,10 @@ mod tests {
|
||||
assert_eq!(app.data.radarr_data.log_details.items[1].to_string(), "2");
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&None,
|
||||
active_radarr_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -611,10 +591,10 @@ mod tests {
|
||||
assert_eq!(app.data.radarr_data.log_details.items[1].to_string(), "22");
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&None,
|
||||
active_radarr_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -629,20 +609,20 @@ mod tests {
|
||||
let mut app = App::default();
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemTaskStartConfirmPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemTaskStartConfirmPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert!(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&key,
|
||||
key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemTaskStartConfirmPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemTaskStartConfirmPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -664,17 +644,12 @@ mod tests {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data.updates = ScrollableText::with_string("Test".to_owned());
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemTasks,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
SystemDetailsHandler::with(SUBMIT_KEY, &mut app, ActiveRadarrBlock::SystemTasks, None)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::SystemTaskStartConfirmPrompt.into()
|
||||
ActiveRadarrBlock::SystemTaskStartConfirmPrompt.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -685,17 +660,12 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::SystemTasks.into());
|
||||
app.data.radarr_data.updates = ScrollableText::with_string("Test".to_owned());
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemTasks,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
SystemDetailsHandler::with(SUBMIT_KEY, &mut app, ActiveRadarrBlock::SystemTasks, None)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::SystemTasks.into()
|
||||
ActiveRadarrBlock::SystemTasks.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -708,10 +678,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::SystemTaskStartConfirmPrompt.into());
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemTaskStartConfirmPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemTaskStartConfirmPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -722,7 +692,7 @@ mod tests {
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::SystemTasks.into()
|
||||
ActiveRadarrBlock::SystemTasks.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -734,10 +704,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::SystemTaskStartConfirmPrompt.into());
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&SUBMIT_KEY,
|
||||
SUBMIT_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemTaskStartConfirmPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemTaskStartConfirmPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -745,7 +715,7 @@ mod tests {
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::SystemTasks.into()
|
||||
ActiveRadarrBlock::SystemTasks.into()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -776,10 +746,9 @@ mod tests {
|
||||
.log_details
|
||||
.set_items(vec![HorizontallyScrollableText::default()]);
|
||||
|
||||
SystemDetailsHandler::with(&ESC_KEY, &mut app, &ActiveRadarrBlock::SystemLogs, &None)
|
||||
.handle();
|
||||
SystemDetailsHandler::with(ESC_KEY, &mut app, ActiveRadarrBlock::SystemLogs, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::System.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::System.into());
|
||||
assert!(app.data.radarr_data.log_details.items.is_empty());
|
||||
}
|
||||
|
||||
@@ -795,10 +764,9 @@ mod tests {
|
||||
.tasks
|
||||
.set_items(vec![RadarrTask::default()]);
|
||||
|
||||
SystemDetailsHandler::with(&ESC_KEY, &mut app, &ActiveRadarrBlock::SystemTasks, &None)
|
||||
.handle();
|
||||
SystemDetailsHandler::with(ESC_KEY, &mut app, ActiveRadarrBlock::SystemTasks, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::System.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::System.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -814,14 +782,14 @@ mod tests {
|
||||
.set_items(vec![QueueEvent::default()]);
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemQueuedEvents,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemQueuedEvents,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::System.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::System.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -831,10 +799,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::System.into());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::SystemUpdates.into());
|
||||
|
||||
SystemDetailsHandler::with(&ESC_KEY, &mut app, &ActiveRadarrBlock::SystemUpdates, &None)
|
||||
SystemDetailsHandler::with(ESC_KEY, &mut app, ActiveRadarrBlock::SystemUpdates, None)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::System.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::System.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -845,16 +813,16 @@ mod tests {
|
||||
app.data.radarr_data.prompt_confirm = true;
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&ESC_KEY,
|
||||
ESC_KEY,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemTaskStartConfirmPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemTaskStartConfirmPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::SystemTasks.into()
|
||||
ActiveRadarrBlock::SystemTasks.into()
|
||||
);
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
@@ -882,14 +850,14 @@ mod tests {
|
||||
app.push_navigation_stack(active_radarr_block.into());
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.refresh.key,
|
||||
DEFAULT_KEYBINDINGS.refresh.key,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&None,
|
||||
active_radarr_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &active_radarr_block.into());
|
||||
assert_eq!(app.get_current_route(), active_radarr_block.into());
|
||||
assert!(app.should_refresh);
|
||||
}
|
||||
|
||||
@@ -909,14 +877,14 @@ mod tests {
|
||||
app.push_navigation_stack(active_radarr_block.into());
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.refresh.key,
|
||||
DEFAULT_KEYBINDINGS.refresh.key,
|
||||
&mut app,
|
||||
&active_radarr_block,
|
||||
&None,
|
||||
active_radarr_block,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &active_radarr_block.into());
|
||||
assert_eq!(app.get_current_route(), active_radarr_block.into());
|
||||
assert!(!app.should_refresh);
|
||||
}
|
||||
|
||||
@@ -928,10 +896,10 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::SystemTaskStartConfirmPrompt.into());
|
||||
|
||||
SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.confirm.key,
|
||||
DEFAULT_KEYBINDINGS.confirm.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemTaskStartConfirmPrompt,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemTaskStartConfirmPrompt,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
@@ -942,7 +910,7 @@ mod tests {
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::SystemTasks.into()
|
||||
ActiveRadarrBlock::SystemTasks.into()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -951,9 +919,9 @@ mod tests {
|
||||
fn test_system_details_handler_accepts() {
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if SYSTEM_DETAILS_BLOCKS.contains(&active_radarr_block) {
|
||||
assert!(SystemDetailsHandler::accepts(&active_radarr_block));
|
||||
assert!(SystemDetailsHandler::accepts(active_radarr_block));
|
||||
} else {
|
||||
assert!(!SystemDetailsHandler::accepts(&active_radarr_block));
|
||||
assert!(!SystemDetailsHandler::accepts(active_radarr_block));
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -964,10 +932,10 @@ mod tests {
|
||||
app.is_loading = true;
|
||||
|
||||
let handler = SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemUpdates,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemUpdates,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -979,10 +947,10 @@ mod tests {
|
||||
app.is_loading = false;
|
||||
|
||||
let handler = SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemUpdates,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemUpdates,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!handler.is_ready());
|
||||
@@ -999,10 +967,10 @@ mod tests {
|
||||
.set_items(vec![HorizontallyScrollableText::default()]);
|
||||
|
||||
let handler = SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemUpdates,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemUpdates,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
@@ -1015,10 +983,10 @@ mod tests {
|
||||
app.data.radarr_data.updates = ScrollableText::with_string("Test".to_owned());
|
||||
|
||||
let handler = SystemDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.esc.key,
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::SystemUpdates,
|
||||
&None,
|
||||
ActiveRadarrBlock::SystemUpdates,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(handler.is_ready());
|
||||
|
||||
@@ -28,18 +28,18 @@ mod tests {
|
||||
app.data.radarr_data.main_tabs.set_index(6);
|
||||
|
||||
SystemHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.left.key,
|
||||
DEFAULT_KEYBINDINGS.left.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
ActiveRadarrBlock::System,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.main_tabs.get_active_route(),
|
||||
&ActiveRadarrBlock::Indexers.into()
|
||||
ActiveRadarrBlock::Indexers.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -49,18 +49,18 @@ mod tests {
|
||||
app.data.radarr_data.main_tabs.set_index(6);
|
||||
|
||||
SystemHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.right.key,
|
||||
DEFAULT_KEYBINDINGS.right.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
ActiveRadarrBlock::System,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.data.radarr_data.main_tabs.get_active_route(),
|
||||
&ActiveRadarrBlock::Movies.into()
|
||||
ActiveRadarrBlock::Movies.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::Movies.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,9 +79,9 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::System.into());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::System.into());
|
||||
|
||||
SystemHandler::with(&ESC_KEY, &mut app, &ActiveRadarrBlock::System, &None).handle();
|
||||
SystemHandler::with(ESC_KEY, &mut app, ActiveRadarrBlock::System, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::System.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::System.into());
|
||||
assert!(app.error.text.is_empty());
|
||||
}
|
||||
}
|
||||
@@ -112,16 +112,16 @@ mod tests {
|
||||
.set_items(vec![RadarrTask::default()]);
|
||||
|
||||
SystemHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.update.key,
|
||||
DEFAULT_KEYBINDINGS.update.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
ActiveRadarrBlock::System,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::SystemUpdates.into()
|
||||
ActiveRadarrBlock::SystemUpdates.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -146,14 +146,14 @@ mod tests {
|
||||
.set_items(vec![RadarrTask::default()]);
|
||||
|
||||
SystemHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.update.key,
|
||||
DEFAULT_KEYBINDINGS.update.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
ActiveRadarrBlock::System,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::System.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::System.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -175,16 +175,16 @@ mod tests {
|
||||
.set_items(vec![RadarrTask::default()]);
|
||||
|
||||
SystemHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.events.key,
|
||||
DEFAULT_KEYBINDINGS.events.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
ActiveRadarrBlock::System,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::SystemQueuedEvents.into()
|
||||
ActiveRadarrBlock::SystemQueuedEvents.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -209,14 +209,14 @@ mod tests {
|
||||
.set_items(vec![RadarrTask::default()]);
|
||||
|
||||
SystemHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.events.key,
|
||||
DEFAULT_KEYBINDINGS.events.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
ActiveRadarrBlock::System,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::System.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::System.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -239,14 +239,14 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::System.into());
|
||||
|
||||
SystemHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.refresh.key,
|
||||
DEFAULT_KEYBINDINGS.refresh.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
ActiveRadarrBlock::System,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::System.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::System.into());
|
||||
assert!(app.should_refresh);
|
||||
}
|
||||
|
||||
@@ -272,14 +272,14 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveRadarrBlock::System.into());
|
||||
|
||||
SystemHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.refresh.key,
|
||||
DEFAULT_KEYBINDINGS.refresh.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
ActiveRadarrBlock::System,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::System.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::System.into());
|
||||
assert!(!app.should_refresh);
|
||||
}
|
||||
|
||||
@@ -302,16 +302,16 @@ mod tests {
|
||||
.set_items(vec![RadarrTask::default()]);
|
||||
|
||||
SystemHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.logs.key,
|
||||
DEFAULT_KEYBINDINGS.logs.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
ActiveRadarrBlock::System,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::SystemLogs.into()
|
||||
ActiveRadarrBlock::SystemLogs.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.data.radarr_data.log_details.items,
|
||||
@@ -344,14 +344,14 @@ mod tests {
|
||||
.set_items(vec![RadarrTask::default()]);
|
||||
|
||||
SystemHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.logs.key,
|
||||
DEFAULT_KEYBINDINGS.logs.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
ActiveRadarrBlock::System,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::System.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::System.into());
|
||||
assert!(app.data.radarr_data.log_details.is_empty());
|
||||
}
|
||||
|
||||
@@ -374,16 +374,16 @@ mod tests {
|
||||
.set_items(vec![RadarrTask::default()]);
|
||||
|
||||
SystemHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.tasks.key,
|
||||
DEFAULT_KEYBINDINGS.tasks.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
ActiveRadarrBlock::System,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::SystemTasks.into()
|
||||
ActiveRadarrBlock::SystemTasks.into()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -408,14 +408,14 @@ mod tests {
|
||||
.set_items(vec![RadarrTask::default()]);
|
||||
|
||||
SystemHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.tasks.key,
|
||||
DEFAULT_KEYBINDINGS.tasks.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
ActiveRadarrBlock::System,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::System.into());
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::System.into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,9 +444,9 @@ mod tests {
|
||||
|
||||
ActiveRadarrBlock::iter().for_each(|active_radarr_block| {
|
||||
if system_blocks.contains(&active_radarr_block) {
|
||||
assert!(SystemHandler::accepts(&active_radarr_block));
|
||||
assert!(SystemHandler::accepts(active_radarr_block));
|
||||
} else {
|
||||
assert!(!SystemHandler::accepts(&active_radarr_block));
|
||||
assert!(!SystemHandler::accepts(active_radarr_block));
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -457,10 +457,10 @@ mod tests {
|
||||
app.is_loading = true;
|
||||
|
||||
let system_handler = SystemHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.update.key,
|
||||
DEFAULT_KEYBINDINGS.update.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
ActiveRadarrBlock::System,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!system_handler.is_ready());
|
||||
@@ -482,10 +482,10 @@ mod tests {
|
||||
.set_items(vec![QueueEvent::default()]);
|
||||
|
||||
let system_handler = SystemHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.update.key,
|
||||
DEFAULT_KEYBINDINGS.update.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
ActiveRadarrBlock::System,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!system_handler.is_ready());
|
||||
@@ -503,10 +503,10 @@ mod tests {
|
||||
.set_items(vec![QueueEvent::default()]);
|
||||
|
||||
let system_handler = SystemHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.update.key,
|
||||
DEFAULT_KEYBINDINGS.update.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
ActiveRadarrBlock::System,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!system_handler.is_ready());
|
||||
@@ -524,10 +524,10 @@ mod tests {
|
||||
.set_items(vec![RadarrTask::default()]);
|
||||
|
||||
let system_handler = SystemHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.update.key,
|
||||
DEFAULT_KEYBINDINGS.update.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
ActiveRadarrBlock::System,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(!system_handler.is_ready());
|
||||
@@ -550,10 +550,10 @@ mod tests {
|
||||
.set_items(vec![QueueEvent::default()]);
|
||||
|
||||
let system_handler = SystemHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.update.key,
|
||||
DEFAULT_KEYBINDINGS.update.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
ActiveRadarrBlock::System,
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(system_handler.is_ready());
|
||||
|
||||
Reference in New Issue
Block a user