From 61a18cb2221b827a114b2d5905e09642433cddb5 Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Thu, 3 Sep 2026 13:11:51 -0600 Subject: [PATCH] fix(readarr): move the book file delete to the File tab Pressing Del on the Editions tab opened a delete prompt operating on the currently selected book file, which is not visible from that tab. On the File tab, where the book files are listed, Del did nothing even though the tab advertised a "delete book file" hint. Gate the delete on the File tab instead and drop the now inaccurate hint from the Editions tab clue set. A Readarr edition carries no file id, unlike a Lidarr track, so the book files live in their own table and the delete cannot be driven from the editions table. --- src/app/readarr/readarr_context_clues.rs | 3 +- .../readarr/readarr_context_clues_tests.rs | 4 --- .../library/book_details_handler.rs | 2 +- .../library/book_details_handler_tests.rs | 28 ++++++++++++++----- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/app/readarr/readarr_context_clues.rs b/src/app/readarr/readarr_context_clues.rs index aad10fec..442fabbb 100644 --- a/src/app/readarr/readarr_context_clues.rs +++ b/src/app/readarr/readarr_context_clues.rs @@ -93,7 +93,7 @@ pub static MANUAL_AUTHOR_SEARCH_CONTEXT_CLUES: [ContextClue; 7] = [ (DEFAULT_KEYBINDINGS.esc, DEFAULT_KEYBINDINGS.esc.desc), ]; -pub static BOOK_DETAILS_CONTEXT_CLUES: [ContextClue; 6] = [ +pub static BOOK_DETAILS_CONTEXT_CLUES: [ContextClue; 5] = [ ( DEFAULT_KEYBINDINGS.refresh, DEFAULT_KEYBINDINGS.refresh.desc, @@ -105,7 +105,6 @@ pub static BOOK_DETAILS_CONTEXT_CLUES: [ContextClue; 6] = [ ), (DEFAULT_KEYBINDINGS.esc, DEFAULT_KEYBINDINGS.esc.desc), (DEFAULT_KEYBINDINGS.submit, "edition details"), - (DEFAULT_KEYBINDINGS.delete, "delete book file"), ]; pub static BOOK_HISTORY_CONTEXT_CLUES: [ContextClue; 7] = [ diff --git a/src/app/readarr/readarr_context_clues_tests.rs b/src/app/readarr/readarr_context_clues_tests.rs index 47cb11af..76eb259b 100644 --- a/src/app/readarr/readarr_context_clues_tests.rs +++ b/src/app/readarr/readarr_context_clues_tests.rs @@ -269,10 +269,6 @@ mod tests { book_details_context_clues_iter.next(), &(DEFAULT_KEYBINDINGS.submit, "edition details") ); - assert_some_eq_x!( - book_details_context_clues_iter.next(), - &(DEFAULT_KEYBINDINGS.delete, "delete book file") - ); assert_none!(book_details_context_clues_iter.next()); } diff --git a/src/handlers/readarr_handlers/library/book_details_handler.rs b/src/handlers/readarr_handlers/library/book_details_handler.rs index b49a60d9..092b46b5 100644 --- a/src/handlers/readarr_handlers/library/book_details_handler.rs +++ b/src/handlers/readarr_handlers/library/book_details_handler.rs @@ -260,7 +260,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveReadarrBlock> for BookDetailsHandler< fn handle_end(&mut self) {} fn handle_delete(&mut self) { - if self.active_readarr_block == ActiveReadarrBlock::BookDetails + if self.active_readarr_block == ActiveReadarrBlock::BookFileInfo && self.book_files_are_populated() { self diff --git a/src/handlers/readarr_handlers/library/book_details_handler_tests.rs b/src/handlers/readarr_handlers/library/book_details_handler_tests.rs index e539fb12..e092410c 100644 --- a/src/handlers/readarr_handlers/library/book_details_handler_tests.rs +++ b/src/handlers/readarr_handlers/library/book_details_handler_tests.rs @@ -164,13 +164,25 @@ mod tests { #[test] fn test_delete_book_file_prompt() { + let mut app = App::test_default(); + app.data.readarr_data.book_details_modal = Some(book_details_modal()); + app.push_navigation_stack(ActiveReadarrBlock::BookFileInfo.into()); + + BookDetailsHandler::new(DELETE_KEY, &mut app, ActiveReadarrBlock::BookFileInfo, None) + .handle(); + + assert_navigation_pushed!(app, ActiveReadarrBlock::DeleteBookFilePrompt.into()); + } + + #[test] + fn test_delete_book_file_prompt_is_a_no_op_on_the_editions_tab() { let mut app = App::test_default(); app.data.readarr_data.book_details_modal = Some(book_details_modal()); app.push_navigation_stack(ActiveReadarrBlock::BookDetails.into()); BookDetailsHandler::new(DELETE_KEY, &mut app, ActiveReadarrBlock::BookDetails, None).handle(); - assert_navigation_pushed!(app, ActiveReadarrBlock::DeleteBookFilePrompt.into()); + assert_navigation_pushed!(app, ActiveReadarrBlock::BookDetails.into()); } #[test] @@ -179,11 +191,12 @@ mod tests { let mut modal = book_details_modal(); modal.book_files.set_items(Vec::new()); app.data.readarr_data.book_details_modal = Some(modal); - app.push_navigation_stack(ActiveReadarrBlock::BookDetails.into()); + app.push_navigation_stack(ActiveReadarrBlock::BookFileInfo.into()); - BookDetailsHandler::new(DELETE_KEY, &mut app, ActiveReadarrBlock::BookDetails, None).handle(); + BookDetailsHandler::new(DELETE_KEY, &mut app, ActiveReadarrBlock::BookFileInfo, None) + .handle(); - assert_navigation_pushed!(app, ActiveReadarrBlock::BookDetails.into()); + assert_navigation_pushed!(app, ActiveReadarrBlock::BookFileInfo.into()); } #[test] @@ -191,11 +204,12 @@ mod tests { let mut app = App::test_default(); app.is_loading = true; app.data.readarr_data.book_details_modal = Some(book_details_modal()); - app.push_navigation_stack(ActiveReadarrBlock::BookDetails.into()); + app.push_navigation_stack(ActiveReadarrBlock::BookFileInfo.into()); - BookDetailsHandler::new(DELETE_KEY, &mut app, ActiveReadarrBlock::BookDetails, None).handle(); + BookDetailsHandler::new(DELETE_KEY, &mut app, ActiveReadarrBlock::BookFileInfo, None) + .handle(); - assert_navigation_pushed!(app, ActiveReadarrBlock::BookDetails.into()); + assert_navigation_pushed!(app, ActiveReadarrBlock::BookFileInfo.into()); } }