Deletion on and offline restored.

This commit is contained in:
2026-02-17 00:52:02 -06:00
parent 9ce31a6e09
commit 1242999b35
3 changed files with 186 additions and 2 deletions
+49 -2
View File
@@ -668,6 +668,54 @@ fn handle_key(app: &mut App, code: KeyCode) {
}
}
// Capital X: delete local copy/copies for hovered item (works same online/offline)
if matches!(code, KeyCode::Char('X')) {
let result = match app.current_view() {
View::Library { items, selected, .. } if !items.is_empty() => {
let id = items[*selected].id.clone();
crate::core::downloads::delete_local_by_item_id(&id)
}
View::OfflineLibrary { entries, selected, .. } if !entries.is_empty() => {
let e = &entries[*selected];
if e.is_dir {
app.status = "X: select a file (not a folder)".into();
return;
}
crate::core::downloads::delete_local_by_path(&e.path)
}
_ => {
app.status = "X: nothing deletable here".into();
return;
}
};
match result {
Ok(n) => {
// refresh downloaded-id index so 💾 updates immediately
app.downloaded_ids = crate::core::downloads::scan_downloaded_ids().unwrap_or_default();
// if were in OfflineLibrary, refresh the directory listing so the file disappears
if let Some(View::OfflineLibrary { dir, entries, selected, .. }) = app.view_stack.last_mut() {
*entries = offline_list_dir(dir);
if !entries.is_empty() {
*selected = (*selected).min(entries.len() - 1);
} else {
*selected = 0;
}
}
app.status = format!("Deleted local copies: {n}");
}
Err(e) => {
app.status = format!("Delete failed: {e}");
}
}
return;
}
// Mark watched (w) / Unmark watched (W)
if matches!(code, KeyCode::Char('w') | KeyCode::Char('W')) {
let unmark = matches!(code, KeyCode::Char('W'));
@@ -1199,7 +1247,6 @@ fn handle_key(app: &mut App, code: KeyCode) {
return;
}
KeyCode::Char('q') => app.should_exit = true,
//Enter code Block
@@ -1903,7 +1950,7 @@ fn ui(frame: &mut Frame, app: &App) {
.unwrap_or("-");
let right_text = format!(
"{connected}\n\np/P: play/autoplay
"{connected}\np/P: play/autoplay
r/R: resume/autoplay
d: download / cancel
q: quit