Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
bin/patch: Replace manual filter-collect
Matthias Beyer committed 5 months ago
commit d3dcfd8e0935042faa4c715bb2122e76f83ea0f5
parent 87724450835159c1f9314f21036c92c25f896549
1 file changed +7 -6
modified bin/commands/patch/list.rs
@@ -114,12 +114,13 @@ impl TryFrom<&Context> for State {
        let filter = PatchItemFilter::from_str(&context.filter.to_string()).unwrap_or_default();

        // 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);
-
            }
-
        }
+
        let mut items: Vec<_> = patches
+
            .into_iter()
+
            .flat_map(|patch| {
+
                PatchItem::new(&context.profile, &context.repository, patch.clone()).ok()
+
            })
+
            .collect();
+

        items.sort_by(|a, b| b.timestamp.cmp(&a.timestamp));

        Ok(Self {