Radish alpha
r
rad:z39mP9rQAaGmERfUMPULfPUi473tY
Radicle terminal user interface
Radicle
Git
patch: Change default filter
Merged did:key:z6MkswQE...2C1V opened 2 years ago
2 files changed +10 -5 4339e29e 92e677fa
modified 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 },
        };
modified bin/commands/patch/flux/select.rs
@@ -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 {