refactor(handlers): Refactored the handlers to all use the handle_table_events macro when appropriate and created tests for the macro so tests don't have to be duplicated across each handler

This commit is contained in:
2024-12-11 17:03:52 -07:00
parent c09950d0af
commit ed2211586e
44 changed files with 1592 additions and 9288 deletions
@@ -3,11 +3,10 @@ use crate::app::App;
use crate::event::Key;
use crate::handle_table_events;
use crate::handlers::sonarr_handlers::handle_change_tab_left_right_keys;
use crate::handlers::table_handler::TableHandlingProps;
use crate::handlers::table_handler::TableHandlingConfig;
use crate::handlers::{handle_clear_errors, handle_prompt_toggle, KeyEventHandler};
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, DOWNLOADS_BLOCKS};
use crate::models::sonarr_models::DownloadRecord;
use crate::models::Scrollable;
use crate::network::sonarr_network::SonarrEvent;
#[cfg(test)]
@@ -32,10 +31,10 @@ impl<'a, 'b> DownloadsHandler<'a, 'b> {
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for DownloadsHandler<'a, 'b> {
fn handle(&mut self) {
let download_table_handling_props =
TableHandlingProps::new(ActiveSonarrBlock::Downloads.into());
let download_table_handling_config =
TableHandlingConfig::new(ActiveSonarrBlock::Downloads.into());
if !self.handle_downloads_table_events(download_table_handling_props) {
if !self.handle_downloads_table_events(download_table_handling_config) {
self.handle_key_event();
}
}