refactor: Simplified both the table_handler macro and the stateful_table implementation
This commit is contained in:
@@ -5,7 +5,6 @@ use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||
ADD_SERIES_BLOCKS, ADD_SERIES_SELECTION_BLOCKS, ActiveSonarrBlock,
|
||||
};
|
||||
use crate::models::sonarr_models::{AddSeriesBody, AddSeriesOptions, AddSeriesSearchResult};
|
||||
use crate::models::stateful_table::StatefulTable;
|
||||
use crate::models::{BlockSelectionState, Scrollable};
|
||||
use crate::network::sonarr_network::SonarrEvent;
|
||||
use crate::{
|
||||
@@ -33,7 +32,7 @@ impl AddSeriesHandler<'_, '_> {
|
||||
.sonarr_data
|
||||
.add_searched_series
|
||||
.as_mut()
|
||||
.unwrap_or(&mut StatefulTable::default()),
|
||||
.expect("add_searched_series should be initialized"),
|
||||
AddSeriesSearchResult
|
||||
);
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for LibraryHandler<'a, '
|
||||
fn handle(&mut self) {
|
||||
let series_table_handling_config = TableHandlingConfig::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())
|
||||
|
||||
@@ -115,7 +115,6 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeasonDetailsHandler
|
||||
TableHandlingConfig::new(ActiveSonarrBlock::SeasonHistory.into())
|
||||
.sorting_block(ActiveSonarrBlock::SeasonHistorySortPrompt.into())
|
||||
.sort_options(history_sorting_options())
|
||||
.sort_by_fn(|a: &SonarrHistoryItem, b: &SonarrHistoryItem| a.id.cmp(&b.id))
|
||||
.searching_block(ActiveSonarrBlock::SearchSeasonHistory.into())
|
||||
.search_error_block(ActiveSonarrBlock::SearchSeasonHistoryError.into())
|
||||
.search_field_fn(|history_item: &SonarrHistoryItem| &history_item.source_title.text)
|
||||
|
||||
@@ -71,7 +71,6 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeriesDetailsHandler
|
||||
TableHandlingConfig::new(ActiveSonarrBlock::SeriesHistory.into())
|
||||
.sorting_block(ActiveSonarrBlock::SeriesHistorySortPrompt.into())
|
||||
.sort_options(history_sorting_options())
|
||||
.sort_by_fn(|a: &SonarrHistoryItem, b: &SonarrHistoryItem| a.id.cmp(&b.id))
|
||||
.searching_block(ActiveSonarrBlock::SearchSeriesHistory.into())
|
||||
.search_error_block(ActiveSonarrBlock::SearchSeriesHistoryError.into())
|
||||
.search_field_fn(|history_item: &SonarrHistoryItem| &history_item.source_title.text)
|
||||
|
||||
Reference in New Issue
Block a user