diff --git a/bin/commands/patch.rs b/bin/commands/patch.rs index b78d434a..534f7a41 100644 --- a/bin/commands/patch.rs +++ b/bin/commands/patch.rs @@ -14,7 +14,7 @@ use anyhow::anyhow; use radicle::identity::RepoId; use radicle_tui as tui; -use tui::common::cob::patch::{self, State}; +use tui::common::cob::patch::{self, Filter, State}; use tui::common::log; use crate::terminal; @@ -136,6 +136,10 @@ impl Args for Options { } } + if select_opts.mode == common::Mode::Id { + select_opts.filter = Filter::default().with_state(None) + } + let op = match op.ok_or_else(|| anyhow!("an operation must be provided"))? { OperationName::Select => Operation::Select { opts: select_opts }, }; diff --git a/bin/commands/patch/flux/select.rs b/bin/commands/patch/flux/select.rs index 4389f52c..d0c4b195 100644 --- a/bin/commands/patch/flux/select.rs +++ b/bin/commands/patch/flux/select.rs @@ -59,12 +59,12 @@ impl TryFrom<&Context> for PatchesState { fn try_from(context: &Context) -> Result { let patches = patch::all(&context.profile, &context.repository)?; let patches = patches - .iter() - .filter(|(_, patch)| context.filter.matches(&context.profile, patch)); - - let mut items = vec![]; + .into_iter() + .filter(|(_, patch)| context.filter.matches(&context.profile, patch)) + .collect::>(); // Convert into UI items + let mut items = vec![]; for patch in patches { if let Ok(item) = PatchItem::new(&context.profile, &context.repository, patch.clone()) { items.push(item); @@ -73,6 +73,7 @@ impl TryFrom<&Context> for PatchesState { // Apply sorting items.sort_by(|a, b| b.timestamp.cmp(&a.timestamp)); + let selected = items.first().cloned(); Ok(Self {