feat(handler): Support for deleting a series in Sonarr

This commit is contained in:
2024-12-02 11:30:34 -07:00
parent b75a95a708
commit b1bdc19afb
6 changed files with 495 additions and 13 deletions
+11 -3
View File
@@ -1,3 +1,5 @@
use delete_series_handler::DeleteSeriesHandler;
use crate::{
app::App,
event::Key,
@@ -18,6 +20,8 @@ use crate::{
use super::handle_change_tab_left_right_keys;
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
mod delete_series_handler;
#[cfg(test)]
#[path = "library_handler_tests.rs"]
mod library_handler_tests;
@@ -26,12 +30,16 @@ pub(super) struct LibraryHandler<'a, 'b> {
key: Key,
app: &'a mut App<'b>,
active_sonarr_block: ActiveSonarrBlock,
_context: Option<ActiveSonarrBlock>,
context: Option<ActiveSonarrBlock>,
}
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for LibraryHandler<'a, 'b> {
fn handle(&mut self) {
match self.active_sonarr_block {
_ if DeleteSeriesHandler::accepts(self.active_sonarr_block) => {
DeleteSeriesHandler::with(self.key, self.app, self.active_sonarr_block, self.context)
.handle();
}
_ => self.handle_key_event(),
}
}
@@ -44,13 +52,13 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for LibraryHandler<'a, '
key: Key,
app: &'a mut App<'b>,
active_block: ActiveSonarrBlock,
_context: Option<ActiveSonarrBlock>,
context: Option<ActiveSonarrBlock>,
) -> LibraryHandler<'a, 'b> {
LibraryHandler {
key,
app,
active_sonarr_block: active_block,
_context,
context,
}
}