incomplete downloads, but backup

This commit is contained in:
2026-02-16 14:48:11 -06:00
parent 6d5b4eec1d
commit 68c0a84440
2 changed files with 66 additions and 42 deletions

View File

@@ -779,32 +779,34 @@ fn handle_key(app: &mut App, code: KeyCode) {
let mut handled_by_downloads = false;
if app.downloads_focus {
match code {
KeyCode::Up | KeyCode::Char('k') => {
if app.downloads_selected > 0 {
app.downloads_selected -= 1;
}
handled_by_downloads = true;
}
KeyCode::Down | KeyCode::Char('j') => {
let len = app
.downloads
.as_ref()
.and_then(|dm| dm.state.lock().ok())
.map(|st| st.queue.len())
.unwrap_or(0);
if let Some(dm) = &app.downloads {
let idx = app.downloads_selected;
if len > 0 && app.downloads_selected + 1 < len {
app.downloads_selected += 1;
}
handled_by_downloads = true;
if idx == 0 {
dm.send(downloads::DownloadCommand::Cancel { index: 0 });
app.status = "download: cancel active".into();
} else {
dm.send(downloads::DownloadCommand::RemoveQueued { index: idx });
app.status = "download: removed".into();
}
KeyCode::Esc => {
app.downloads_focus = false;
handled_by_downloads = true;
// Clamp selection immediately to avoid focus navigation glitches
let len = dm
.state
.lock()
.ok()
.map(|st| st.queue.len())
.unwrap_or(0);
if len == 0 {
app.downloads_selected = 0;
} else if app.downloads_selected >= len {
app.downloads_selected = len - 1;
}
_ => {}
} else {
app.status = "downloads not available".into();
}
return;
}
// If downloads handled the key, skip normal navigation handling