patch: Change default filter

This commit is contained in:
Erik Kundt
2024-03-06 12:34:00 +01:00
parent 4339e29e2f
commit 92e677fa10
2 changed files with 10 additions and 5 deletions
+5 -1
View File
@@ -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 },
};
+5 -4
View File
@@ -59,12 +59,12 @@ impl TryFrom<&Context> for PatchesState {
fn try_from(context: &Context) -> Result<Self, Self::Error> {
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::<Vec<_>>();
// 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 {