diff options
Diffstat (limited to 'src/select/cmds.rs')
-rw-r--r-- | src/select/cmds.rs | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/select/cmds.rs b/src/select/cmds.rs index 40e5b17..85e655f 100644 --- a/src/select/cmds.rs +++ b/src/select/cmds.rs @@ -25,41 +25,46 @@ pub async fn handle_select_cmd( cmd: SelectCommand, line_number: Option<i64>, ) -> Result<()> { + fn compute_priority(line_number: Option<i64>, priority: Option<i64>) -> Option<i64> { + if let Some(pri) = priority { + Some(pri) + } else if let Some(pri) = line_number { + Some(pri) + } else { + None + } + } + match cmd { SelectCommand::Pick { shared } => { + let priority = compute_priority(line_number, shared.priority); set_video_status( app, &shared.hash.realize(app).await?, VideoStatus::Pick, - line_number, + priority, ) .await? } SelectCommand::Drop { shared } => { + let priority = compute_priority(line_number, shared.priority); set_video_status( app, &shared.hash.realize(app).await?, VideoStatus::Drop, - line_number, + priority, ) .await? } SelectCommand::Watch { shared, - priority, subtitle_langs, speed, } => { let hash = shared.hash.realize(&app).await?; let video = get_video_by_hash(app, &hash).await?; let video_options = VideoOptions::new(subtitle_langs, speed); - let priority = if let Some(pri) = priority { - Some(pri) - } else if let Some(pri) = line_number { - Some(pri) - } else { - None - }; + let priority = compute_priority(line_number, shared.priority); if let Some(_) = video.cache_path { set_video_status(app, &hash, VideoStatus::Cached, priority).await?; |