downloading 90% done
This commit is contained in:
87
src/main.rs
87
src/main.rs
@@ -523,6 +523,75 @@ fn handle_key(app: &mut App, code: KeyCode) {
|
||||
return;
|
||||
}
|
||||
|
||||
// --------------------
|
||||
// Downloads Focus Modal
|
||||
// --------------------
|
||||
if app.downloads_focus {
|
||||
match code {
|
||||
KeyCode::Esc => {
|
||||
app.downloads_focus = false;
|
||||
app.status = "downloads: unfocus".into();
|
||||
return;
|
||||
}
|
||||
|
||||
KeyCode::Up | KeyCode::Char('k') => {
|
||||
if app.downloads_selected > 0 {
|
||||
app.downloads_selected -= 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
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 len > 0 && app.downloads_selected + 1 < len {
|
||||
app.downloads_selected += 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
KeyCode::Char('d') => {
|
||||
if let Some(dm) = &app.downloads {
|
||||
let idx = app.downloads_selected;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
// Clamp selection after removal
|
||||
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;
|
||||
}
|
||||
|
||||
// Swallow everything else while focused.
|
||||
_ => return,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// mpv controls (only when not typing into search/login)
|
||||
if app.search.is_none() && !matches!(app.current_view(), View::Login) {
|
||||
match code {
|
||||
@@ -775,6 +844,7 @@ fn handle_key(app: &mut App, code: KeyCode) {
|
||||
}
|
||||
}
|
||||
|
||||
// downloads focus overrides normal navigation
|
||||
// downloads focus overrides normal navigation
|
||||
let mut handled_by_downloads = false;
|
||||
|
||||
@@ -816,23 +886,6 @@ fn handle_key(app: &mut App, code: KeyCode) {
|
||||
|
||||
match code {
|
||||
KeyCode::Char('d') => {
|
||||
// downloads: focus => cancel/remove, otherwise enqueue selected item
|
||||
if app.downloads_focus {
|
||||
if let Some(dm) = &app.downloads {
|
||||
let idx = app.downloads_selected;
|
||||
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();
|
||||
}
|
||||
} else {
|
||||
app.status = "downloads not available".into();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let cfg = match &app.config {
|
||||
Some(c) => c.clone(),
|
||||
None => { app.status = "No config loaded".into(); return; }
|
||||
|
||||
Reference in New Issue
Block a user