mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-21 18:40:46 +08:00
patch: Change default filter
This commit is contained in:
@@ -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 },
|
||||
};
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user