fix: Pass the delete movie params in with the DeleteMovie event when publishing to the networking channel
This commit is contained in:
@@ -2,6 +2,7 @@ use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||
use crate::app::App;
|
||||
use crate::event::Key;
|
||||
use crate::handlers::{handle_prompt_toggle, KeyEventHandler};
|
||||
use crate::models::radarr_models::DeleteMovieParams;
|
||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, DELETE_MOVIE_BLOCKS};
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
|
||||
@@ -16,6 +17,25 @@ pub(super) struct DeleteMovieHandler<'a, 'b> {
|
||||
_context: Option<ActiveRadarrBlock>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> DeleteMovieHandler<'a, 'b> {
|
||||
fn build_delete_movie_params(&mut self) -> DeleteMovieParams {
|
||||
let id = self.app.data.radarr_data.movies.current_selection().id;
|
||||
let delete_movie_files = self.app.data.radarr_data.delete_movie_files;
|
||||
let add_list_exclusion = self.app.data.radarr_data.add_list_exclusion;
|
||||
self
|
||||
.app
|
||||
.data
|
||||
.radarr_data
|
||||
.reset_delete_movie_preferences();
|
||||
|
||||
DeleteMovieParams {
|
||||
id,
|
||||
delete_movie_files,
|
||||
add_list_exclusion,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DeleteMovieHandler<'a, 'b> {
|
||||
fn accepts(active_block: ActiveRadarrBlock) -> bool {
|
||||
DELETE_MOVIE_BLOCKS.contains(&active_block)
|
||||
@@ -72,7 +92,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DeleteMovieHandler<'
|
||||
match self.app.data.radarr_data.selected_block.get_active_block() {
|
||||
ActiveRadarrBlock::DeleteMovieConfirmPrompt => {
|
||||
if self.app.data.radarr_data.prompt_confirm {
|
||||
self.app.data.radarr_data.prompt_confirm_action = Some(RadarrEvent::DeleteMovie(None));
|
||||
self.app.data.radarr_data.prompt_confirm_action = Some(RadarrEvent::DeleteMovie(self.build_delete_movie_params()));
|
||||
self.app.should_refresh = true;
|
||||
} else {
|
||||
self.app.data.radarr_data.reset_delete_movie_preferences();
|
||||
@@ -108,7 +128,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DeleteMovieHandler<'
|
||||
&& self.key == DEFAULT_KEYBINDINGS.confirm.key
|
||||
{
|
||||
self.app.data.radarr_data.prompt_confirm = true;
|
||||
self.app.data.radarr_data.prompt_confirm_action = Some(RadarrEvent::DeleteMovie(None));
|
||||
self.app.data.radarr_data.prompt_confirm_action = Some(RadarrEvent::DeleteMovie(self.build_delete_movie_params()));
|
||||
self.app.should_refresh = true;
|
||||
|
||||
self.app.pop_navigation_stack();
|
||||
|
||||
Reference in New Issue
Block a user