refactor: Migrated the handle_table_events macro into a trait for better IDE support, created a TableEventAdapter wrapper for the KeyEventHandlers to make it so that the trait can be used properly and a simple function to replace the previous call to the handle_table_events macro
This commit is contained in:
@@ -4,16 +4,15 @@ use crate::handlers::radarr_handlers::handle_change_tab_left_right_keys;
|
||||
use crate::handlers::radarr_handlers::indexers::edit_indexer_handler::EditIndexerHandler;
|
||||
use crate::handlers::radarr_handlers::indexers::edit_indexer_settings_handler::IndexerSettingsHandler;
|
||||
use crate::handlers::radarr_handlers::indexers::test_all_indexers_handler::TestAllIndexersHandler;
|
||||
use crate::handlers::table_handler::TableHandlingConfig;
|
||||
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
||||
use crate::matches_key;
|
||||
use crate::models::BlockSelectionState;
|
||||
use crate::models::servarr_data::radarr::radarr_data::{
|
||||
ActiveRadarrBlock, EDIT_INDEXER_NZB_SELECTION_BLOCKS, EDIT_INDEXER_TORRENT_SELECTION_BLOCKS,
|
||||
INDEXER_SETTINGS_SELECTION_BLOCKS, INDEXERS_BLOCKS,
|
||||
};
|
||||
use crate::models::servarr_models::Indexer;
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
use crate::{handle_table_events, matches_key};
|
||||
|
||||
mod edit_indexer_handler;
|
||||
mod edit_indexer_settings_handler;
|
||||
@@ -31,8 +30,6 @@ pub(super) struct IndexersHandler<'a, 'b> {
|
||||
}
|
||||
|
||||
impl IndexersHandler<'_, '_> {
|
||||
handle_table_events!(self, indexers, self.app.data.radarr_data.indexers, Indexer);
|
||||
|
||||
fn extract_indexer_id(&self) -> i64 {
|
||||
self.app.data.radarr_data.indexers.current_selection().id
|
||||
}
|
||||
@@ -43,7 +40,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexersHandler<'a,
|
||||
let indexer_table_handling_config =
|
||||
TableHandlingConfig::new(ActiveRadarrBlock::Indexers.into());
|
||||
|
||||
if !self.handle_indexers_table_events(indexer_table_handling_config) {
|
||||
if !handle_table(
|
||||
self,
|
||||
|app| &mut app.data.radarr_data.indexers,
|
||||
indexer_table_handling_config,
|
||||
) {
|
||||
match self.active_radarr_block {
|
||||
_ if EditIndexerHandler::accepts(self.active_radarr_block) => {
|
||||
EditIndexerHandler::new(self.key, self.app, self.active_radarr_block, self.context)
|
||||
@@ -206,4 +207,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexersHandler<'a,
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn app_mut(&mut self) -> &mut App<'b> {
|
||||
self.app
|
||||
}
|
||||
|
||||
fn current_route(&self) -> crate::models::Route {
|
||||
self.app.get_current_route()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user