fix(sonarr): Pass the blocklist item ID alongside the DeleteBlocklistItem event when publishing to the networking channel

This commit is contained in:
2024-12-17 22:22:32 -07:00
parent 478b4ae3c0
commit 906e093152
7 changed files with 40 additions and 29 deletions
@@ -161,7 +161,7 @@ mod tests {
#[case(
ActiveSonarrBlock::Blocklist,
ActiveSonarrBlock::DeleteBlocklistItemPrompt,
SonarrEvent::DeleteBlocklistItem(None)
SonarrEvent::DeleteBlocklistItem(3)
)]
#[case(
ActiveSonarrBlock::Blocklist,
@@ -361,7 +361,7 @@ mod tests {
#[case(
ActiveSonarrBlock::Blocklist,
ActiveSonarrBlock::DeleteBlocklistItemPrompt,
SonarrEvent::DeleteBlocklistItem(None)
SonarrEvent::DeleteBlocklistItem(3)
)]
#[case(
ActiveSonarrBlock::Blocklist,
@@ -512,6 +512,21 @@ mod tests {
}
})
}
#[test]
fn test_extract_blocklist_item_id() {
let mut app = App::default();
app.data.sonarr_data.blocklist.set_items(blocklist_vec());
let blocklist_item_id = BlocklistHandler::with(
DEFAULT_KEYBINDINGS.esc.key,
&mut app,
ActiveSonarrBlock::Blocklist,
None,
).extract_blocklist_item_id();
assert_eq!(blocklist_item_id, 3);
}
#[test]
fn test_blocklist_handler_not_ready_when_loading() {
+12 -2
View File
@@ -28,6 +28,16 @@ impl<'a, 'b> BlocklistHandler<'a, 'b> {
self.app.data.sonarr_data.blocklist,
BlocklistItem
);
fn extract_blocklist_item_id(&self) -> i64 {
self
.app
.data
.sonarr_data
.blocklist
.current_selection()
.id
}
}
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for BlocklistHandler<'a, 'b> {
@@ -99,7 +109,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for BlocklistHandler<'a,
ActiveSonarrBlock::DeleteBlocklistItemPrompt => {
if self.app.data.sonarr_data.prompt_confirm {
self.app.data.sonarr_data.prompt_confirm_action =
Some(SonarrEvent::DeleteBlocklistItem(None));
Some(SonarrEvent::DeleteBlocklistItem(self.extract_blocklist_item_id()));
}
self.app.pop_navigation_stack();
@@ -152,7 +162,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for BlocklistHandler<'a,
if key == DEFAULT_KEYBINDINGS.confirm.key {
self.app.data.sonarr_data.prompt_confirm = true;
self.app.data.sonarr_data.prompt_confirm_action =
Some(SonarrEvent::DeleteBlocklistItem(None));
Some(SonarrEvent::DeleteBlocklistItem(self.extract_blocklist_item_id()));
self.app.pop_navigation_stack();
}