refactor(handler): Created a macro to handle all table key events to reduce code duplication and make future implementations faster; Only refactored the Sonarr library to use it thus far
This commit is contained in:
@@ -195,6 +195,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_series_search_box_home_end_keys() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SearchSeries.into());
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
@@ -248,6 +249,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_series_filter_box_home_end_keys() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::FilterSeries.into());
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
@@ -473,6 +475,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_series_search_box_left_right_keys() {
|
||||
let mut app = App::default();
|
||||
app.data.sonarr_data.series.set_items(vec![Series::default()]);
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SearchSeries.into());
|
||||
app.data.sonarr_data.series.search = Some("Test".into());
|
||||
|
||||
LibraryHandler::with(
|
||||
@@ -521,6 +525,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_series_filter_box_left_right_keys() {
|
||||
let mut app = App::default();
|
||||
app.data.sonarr_data.series.set_items(vec![Series::default()]);
|
||||
app.push_navigation_stack(ActiveSonarrBlock::FilterSeries.into());
|
||||
app.data.sonarr_data.series.filter = Some("Test".into());
|
||||
|
||||
LibraryHandler::with(
|
||||
@@ -860,6 +866,7 @@ mod tests {
|
||||
app.push_navigation_stack(active_sonarr_block.into());
|
||||
app.data.sonarr_data = create_test_sonarr_data();
|
||||
app.data.sonarr_data.series.search = Some("Test".into());
|
||||
app.data.sonarr_data.series.set_items(vec![Series::default()]);
|
||||
|
||||
LibraryHandler::with(ESC_KEY, &mut app, active_sonarr_block, None).handle();
|
||||
|
||||
@@ -868,15 +875,10 @@ mod tests {
|
||||
assert_eq!(app.data.sonarr_data.series.search, None);
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
fn test_filter_series_block_esc(
|
||||
#[values(ActiveSonarrBlock::FilterSeries, ActiveSonarrBlock::FilterSeriesError)]
|
||||
active_sonarr_block: ActiveSonarrBlock,
|
||||
) {
|
||||
#[test]
|
||||
fn test_series_block_esc_resets_filter_if_already_set() {
|
||||
let mut app = App::default();
|
||||
app.should_ignore_quit_key = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
|
||||
app.push_navigation_stack(active_sonarr_block.into());
|
||||
app.data.sonarr_data = create_test_sonarr_data();
|
||||
app.data.sonarr_data.series = StatefulTable {
|
||||
filter: Some("Test".into()),
|
||||
@@ -884,8 +886,32 @@ mod tests {
|
||||
filtered_state: Some(TableState::default()),
|
||||
..StatefulTable::default()
|
||||
};
|
||||
app.data.sonarr_data.series.set_items(vec![Series::default()]);
|
||||
|
||||
LibraryHandler::with(ESC_KEY, &mut app, active_sonarr_block, None).handle();
|
||||
LibraryHandler::with(ESC_KEY, &mut app, ActiveSonarrBlock::Series, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), ActiveSonarrBlock::Series.into());
|
||||
assert_eq!(app.data.sonarr_data.series.filter, None);
|
||||
assert_eq!(app.data.sonarr_data.series.filtered_items, None);
|
||||
assert_eq!(app.data.sonarr_data.series.filtered_state, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_filter_series_error_block_esc() {
|
||||
let mut app = App::default();
|
||||
app.should_ignore_quit_key = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
|
||||
app.push_navigation_stack(ActiveSonarrBlock::FilterSeriesError.into());
|
||||
app.data.sonarr_data = create_test_sonarr_data();
|
||||
app.data.sonarr_data.series = StatefulTable {
|
||||
filter: Some("Test".into()),
|
||||
filtered_items: Some(Vec::new()),
|
||||
filtered_state: Some(TableState::default()),
|
||||
..StatefulTable::default()
|
||||
};
|
||||
app.data.sonarr_data.series.set_items(vec![Series::default()]);
|
||||
|
||||
LibraryHandler::with(ESC_KEY, &mut app, ActiveSonarrBlock::FilterSeriesError, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), ActiveSonarrBlock::Series.into());
|
||||
assert!(!app.should_ignore_quit_key);
|
||||
@@ -916,6 +942,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_series_sort_prompt_block_esc() {
|
||||
let mut app = App::default();
|
||||
app.data.sonarr_data.series.set_items(vec![Series::default()]);
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SeriesSortPrompt.into());
|
||||
|
||||
@@ -932,22 +959,11 @@ mod tests {
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
|
||||
app.data.sonarr_data = create_test_sonarr_data();
|
||||
app.data.sonarr_data.series = StatefulTable {
|
||||
search: Some("Test".into()),
|
||||
filter: Some("Test".into()),
|
||||
filtered_items: Some(Vec::new()),
|
||||
filtered_state: Some(TableState::default()),
|
||||
..StatefulTable::default()
|
||||
};
|
||||
|
||||
LibraryHandler::with(ESC_KEY, &mut app, ActiveSonarrBlock::Series, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), ActiveSonarrBlock::Series.into());
|
||||
assert!(app.error.text.is_empty());
|
||||
assert_eq!(app.data.sonarr_data.series.search, None);
|
||||
assert_eq!(app.data.sonarr_data.series.filter, None);
|
||||
assert_eq!(app.data.sonarr_data.series.filtered_items, None);
|
||||
assert_eq!(app.data.sonarr_data.series.filtered_state, None);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -968,6 +984,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_search_series_key() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
@@ -1020,6 +1037,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_filter_series_key() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
@@ -1274,6 +1292,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_search_series_box_backspace_key() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SearchSeries.into());
|
||||
app.data.sonarr_data.series.search = Some("Test".into());
|
||||
app
|
||||
.data
|
||||
@@ -1298,6 +1317,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_filter_series_box_backspace_key() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::FilterSeries.into());
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
@@ -1322,6 +1342,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_search_series_box_char_key() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SearchSeries.into());
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
@@ -1346,6 +1367,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_filter_series_box_char_key() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::FilterSeries.into());
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
@@ -1370,6 +1392,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_sort_key() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::Series.into());
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
|
||||
@@ -6,7 +6,7 @@ use edit_series_handler::EditSeriesHandler;
|
||||
use crate::{
|
||||
app::App,
|
||||
event::Key,
|
||||
handle_text_box_keys, handle_text_box_left_right_keys,
|
||||
handle_table_events,
|
||||
handlers::{handle_clear_errors, handle_prompt_toggle, KeyEventHandler},
|
||||
models::{
|
||||
servarr_data::sonarr::sonarr_data::{
|
||||
@@ -23,6 +23,7 @@ use crate::{
|
||||
use super::handle_change_tab_left_right_keys;
|
||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||
use crate::handlers::sonarr_handlers::library::series_details_handler::SeriesDetailsHandler;
|
||||
use crate::handlers::table_handler::TableHandlingProps;
|
||||
|
||||
mod add_series_handler;
|
||||
mod delete_series_handler;
|
||||
@@ -39,25 +40,43 @@ pub(super) struct LibraryHandler<'a, 'b> {
|
||||
context: Option<ActiveSonarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> LibraryHandler<'a, 'b> {
|
||||
handle_table_events!(self, series, self.app.data.sonarr_data.series, Series);
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for LibraryHandler<'a, 'b> {
|
||||
fn handle(&mut self) {
|
||||
match self.active_sonarr_block {
|
||||
_ if AddSeriesHandler::accepts(self.active_sonarr_block) => {
|
||||
AddSeriesHandler::with(self.key, self.app, self.active_sonarr_block, self.context).handle();
|
||||
let series_table_handling_props = TableHandlingProps::new(ActiveSonarrBlock::Series.into())
|
||||
.sorting_block(ActiveSonarrBlock::SeriesSortPrompt.into())
|
||||
.sort_by_fn(|a: &Series, b: &Series| a.id.cmp(&b.id))
|
||||
.sort_options(series_sorting_options())
|
||||
.searching_block(ActiveSonarrBlock::SearchSeries.into())
|
||||
.search_error_block(ActiveSonarrBlock::SearchSeriesError.into())
|
||||
.search_field_fn(|series| &series.title.text)
|
||||
.filtering_block(ActiveSonarrBlock::FilterSeries.into())
|
||||
.filter_error_block(ActiveSonarrBlock::FilterSeriesError.into())
|
||||
.filter_field_fn(|series| &series.title.text);
|
||||
|
||||
if !self.handle_series_table_events(series_table_handling_props) {
|
||||
match self.active_sonarr_block {
|
||||
_ if AddSeriesHandler::accepts(self.active_sonarr_block) => {
|
||||
AddSeriesHandler::with(self.key, self.app, self.active_sonarr_block, self.context)
|
||||
.handle();
|
||||
}
|
||||
_ if DeleteSeriesHandler::accepts(self.active_sonarr_block) => {
|
||||
DeleteSeriesHandler::with(self.key, self.app, self.active_sonarr_block, self.context)
|
||||
.handle();
|
||||
}
|
||||
_ if EditSeriesHandler::accepts(self.active_sonarr_block) => {
|
||||
EditSeriesHandler::with(self.key, self.app, self.active_sonarr_block, self.context)
|
||||
.handle();
|
||||
}
|
||||
_ if SeriesDetailsHandler::accepts(self.active_sonarr_block) => {
|
||||
SeriesDetailsHandler::with(self.key, self.app, self.active_sonarr_block, self.context)
|
||||
.handle();
|
||||
}
|
||||
_ => self.handle_key_event(),
|
||||
}
|
||||
_ if DeleteSeriesHandler::accepts(self.active_sonarr_block) => {
|
||||
DeleteSeriesHandler::with(self.key, self.app, self.active_sonarr_block, self.context)
|
||||
.handle();
|
||||
}
|
||||
_ if EditSeriesHandler::accepts(self.active_sonarr_block) => {
|
||||
EditSeriesHandler::with(self.key, self.app, self.active_sonarr_block, self.context)
|
||||
.handle();
|
||||
}
|
||||
_ if SeriesDetailsHandler::accepts(self.active_sonarr_block) => {
|
||||
SeriesDetailsHandler::with(self.key, self.app, self.active_sonarr_block, self.context)
|
||||
.handle();
|
||||
}
|
||||
_ => self.handle_key_event(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,109 +110,13 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for LibraryHandler<'a, '
|
||||
!self.app.is_loading && !self.app.data.sonarr_data.series.is_empty()
|
||||
}
|
||||
|
||||
fn handle_scroll_up(&mut self) {
|
||||
match self.active_sonarr_block {
|
||||
ActiveSonarrBlock::Series => self.app.data.sonarr_data.series.scroll_up(),
|
||||
ActiveSonarrBlock::SeriesSortPrompt => self
|
||||
.app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series
|
||||
.sort
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.scroll_up(),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
fn handle_scroll_up(&mut self) {}
|
||||
|
||||
fn handle_scroll_down(&mut self) {
|
||||
match self.active_sonarr_block {
|
||||
ActiveSonarrBlock::Series => self.app.data.sonarr_data.series.scroll_down(),
|
||||
ActiveSonarrBlock::SeriesSortPrompt => self
|
||||
.app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series
|
||||
.sort
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.scroll_down(),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
fn handle_scroll_down(&mut self) {}
|
||||
|
||||
fn handle_home(&mut self) {
|
||||
match self.active_sonarr_block {
|
||||
ActiveSonarrBlock::Series => self.app.data.sonarr_data.series.scroll_to_top(),
|
||||
ActiveSonarrBlock::SearchSeries => {
|
||||
self
|
||||
.app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series
|
||||
.search
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.scroll_home();
|
||||
}
|
||||
ActiveSonarrBlock::FilterSeries => {
|
||||
self
|
||||
.app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series
|
||||
.filter
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.scroll_home();
|
||||
}
|
||||
ActiveSonarrBlock::SeriesSortPrompt => self
|
||||
.app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series
|
||||
.sort
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.scroll_to_top(),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
fn handle_home(&mut self) {}
|
||||
|
||||
fn handle_end(&mut self) {
|
||||
match self.active_sonarr_block {
|
||||
ActiveSonarrBlock::Series => self.app.data.sonarr_data.series.scroll_to_bottom(),
|
||||
ActiveSonarrBlock::SearchSeries => self
|
||||
.app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series
|
||||
.search
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.reset_offset(),
|
||||
ActiveSonarrBlock::FilterSeries => self
|
||||
.app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series
|
||||
.filter
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.reset_offset(),
|
||||
ActiveSonarrBlock::SeriesSortPrompt => self
|
||||
.app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series
|
||||
.sort
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.scroll_to_bottom(),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
fn handle_end(&mut self) {}
|
||||
|
||||
fn handle_delete(&mut self) {
|
||||
if self.active_sonarr_block == ActiveSonarrBlock::Series {
|
||||
@@ -209,20 +132,6 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for LibraryHandler<'a, '
|
||||
match self.active_sonarr_block {
|
||||
ActiveSonarrBlock::Series => handle_change_tab_left_right_keys(self.app, self.key),
|
||||
ActiveSonarrBlock::UpdateAllSeriesPrompt => handle_prompt_toggle(self.app, self.key),
|
||||
ActiveSonarrBlock::SearchSeries => {
|
||||
handle_text_box_left_right_keys!(
|
||||
self,
|
||||
self.key,
|
||||
self.app.data.sonarr_data.series.search.as_mut().unwrap()
|
||||
)
|
||||
}
|
||||
ActiveSonarrBlock::FilterSeries => {
|
||||
handle_text_box_left_right_keys!(
|
||||
self,
|
||||
self.key,
|
||||
self.app.data.sonarr_data.series.filter.as_mut().unwrap()
|
||||
)
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -232,44 +141,6 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for LibraryHandler<'a, '
|
||||
ActiveSonarrBlock::Series => self
|
||||
.app
|
||||
.push_navigation_stack(ActiveSonarrBlock::SeriesDetails.into()),
|
||||
ActiveSonarrBlock::SearchSeries => {
|
||||
self.app.pop_navigation_stack();
|
||||
self.app.should_ignore_quit_key = false;
|
||||
|
||||
if self.app.data.sonarr_data.series.search.is_some() {
|
||||
let has_match = self
|
||||
.app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series
|
||||
.apply_search(|series| &series.title.text);
|
||||
|
||||
if !has_match {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveSonarrBlock::SearchSeriesError.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
ActiveSonarrBlock::FilterSeries => {
|
||||
self.app.pop_navigation_stack();
|
||||
self.app.should_ignore_quit_key = false;
|
||||
|
||||
if self.app.data.sonarr_data.series.filter.is_some() {
|
||||
let has_matches = self
|
||||
.app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series
|
||||
.apply_filter(|series| &series.title.text);
|
||||
|
||||
if !has_matches {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveSonarrBlock::FilterSeriesError.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
ActiveSonarrBlock::UpdateAllSeriesPrompt => {
|
||||
if self.app.data.sonarr_data.prompt_confirm {
|
||||
self.app.data.sonarr_data.prompt_confirm_action = Some(SonarrEvent::UpdateAllSeries);
|
||||
@@ -277,44 +148,17 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for LibraryHandler<'a, '
|
||||
|
||||
self.app.pop_navigation_stack();
|
||||
}
|
||||
ActiveSonarrBlock::SeriesSortPrompt => {
|
||||
self
|
||||
.app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series
|
||||
.items
|
||||
.sort_by(|a, b| a.id.cmp(&b.id));
|
||||
self.app.data.sonarr_data.series.apply_sorting();
|
||||
|
||||
self.app.pop_navigation_stack();
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_esc(&mut self) {
|
||||
match self.active_sonarr_block {
|
||||
ActiveSonarrBlock::FilterSeries | ActiveSonarrBlock::FilterSeriesError => {
|
||||
self.app.pop_navigation_stack();
|
||||
self.app.data.sonarr_data.series.reset_filter();
|
||||
self.app.should_ignore_quit_key = false;
|
||||
}
|
||||
ActiveSonarrBlock::SearchSeries | ActiveSonarrBlock::SearchSeriesError => {
|
||||
self.app.pop_navigation_stack();
|
||||
self.app.data.sonarr_data.series.reset_search();
|
||||
self.app.should_ignore_quit_key = false;
|
||||
}
|
||||
ActiveSonarrBlock::UpdateAllSeriesPrompt => {
|
||||
self.app.pop_navigation_stack();
|
||||
self.app.data.sonarr_data.prompt_confirm = false;
|
||||
}
|
||||
ActiveSonarrBlock::SeriesSortPrompt => {
|
||||
self.app.pop_navigation_stack();
|
||||
}
|
||||
_ => {
|
||||
self.app.data.sonarr_data.series.reset_search();
|
||||
self.app.data.sonarr_data.series.reset_filter();
|
||||
handle_clear_errors(self.app);
|
||||
}
|
||||
}
|
||||
@@ -324,21 +168,6 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for LibraryHandler<'a, '
|
||||
let key = self.key;
|
||||
match self.active_sonarr_block {
|
||||
ActiveSonarrBlock::Series => match self.key {
|
||||
_ if key == DEFAULT_KEYBINDINGS.search.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveSonarrBlock::SearchSeries.into());
|
||||
self.app.data.sonarr_data.series.search = Some(HorizontallyScrollableText::default());
|
||||
self.app.should_ignore_quit_key = true;
|
||||
}
|
||||
_ if key == DEFAULT_KEYBINDINGS.filter.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveSonarrBlock::FilterSeries.into());
|
||||
self.app.data.sonarr_data.series.reset_filter();
|
||||
self.app.data.sonarr_data.series.filter = Some(HorizontallyScrollableText::default());
|
||||
self.app.should_ignore_quit_key = true;
|
||||
}
|
||||
_ if key == DEFAULT_KEYBINDINGS.edit.key => {
|
||||
self.app.push_navigation_stack(
|
||||
(
|
||||
@@ -366,33 +195,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for LibraryHandler<'a, '
|
||||
_ if key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||
self.app.should_refresh = true;
|
||||
}
|
||||
_ if key == DEFAULT_KEYBINDINGS.sort.key => {
|
||||
self
|
||||
.app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series
|
||||
.sorting(series_sorting_options());
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveSonarrBlock::SeriesSortPrompt.into());
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
ActiveSonarrBlock::SearchSeries => {
|
||||
handle_text_box_keys!(
|
||||
self,
|
||||
key,
|
||||
self.app.data.sonarr_data.series.search.as_mut().unwrap()
|
||||
)
|
||||
}
|
||||
ActiveSonarrBlock::FilterSeries => {
|
||||
handle_text_box_keys!(
|
||||
self,
|
||||
key,
|
||||
self.app.data.sonarr_data.series.filter.as_mut().unwrap()
|
||||
)
|
||||
}
|
||||
ActiveSonarrBlock::UpdateAllSeriesPrompt => {
|
||||
if key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
self.app.data.sonarr_data.prompt_confirm = true;
|
||||
|
||||
@@ -436,8 +436,24 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeriesDetailsHandler
|
||||
self.app.pop_navigation_stack();
|
||||
}
|
||||
ActiveSonarrBlock::SeriesHistory => {
|
||||
if self.app.data.sonarr_data.series_history.as_ref().expect("Series history is not populated").filtered_items.is_some() {
|
||||
self.app.data.sonarr_data.series_history.as_mut().expect("Series history is not populated").reset_filter();
|
||||
if self
|
||||
.app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series_history
|
||||
.as_ref()
|
||||
.expect("Series history is not populated")
|
||||
.filtered_items
|
||||
.is_some()
|
||||
{
|
||||
self
|
||||
.app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series_history
|
||||
.as_mut()
|
||||
.expect("Series history is not populated")
|
||||
.reset_filter();
|
||||
} else {
|
||||
self.app.pop_navigation_stack();
|
||||
self.app.data.sonarr_data.reset_series_info_tabs();
|
||||
@@ -577,14 +593,32 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeriesDetailsHandler
|
||||
handle_text_box_keys!(
|
||||
self,
|
||||
key,
|
||||
self.app.data.sonarr_data.series_history.as_mut().expect("Series history should be populated").search.as_mut().unwrap()
|
||||
self
|
||||
.app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series_history
|
||||
.as_mut()
|
||||
.expect("Series history should be populated")
|
||||
.search
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
)
|
||||
}
|
||||
ActiveSonarrBlock::FilterSeriesHistory => {
|
||||
handle_text_box_keys!(
|
||||
self,
|
||||
key,
|
||||
self.app.data.sonarr_data.series_history.as_mut().expect("Series history should be populated").filter.as_mut().unwrap()
|
||||
self
|
||||
.app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series_history
|
||||
.as_mut()
|
||||
.expect("Series history should be populated")
|
||||
.filter
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
)
|
||||
}
|
||||
ActiveSonarrBlock::AutomaticallySearchSeriesPrompt => {
|
||||
|
||||
Reference in New Issue
Block a user