From 6d026b30daece44a98b04f2c7b3ea173e7a9ffdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dj8yf0=CE=BCl?= Date: Fri, 1 Sep 2023 18:57:04 +0300 Subject: [PATCH] feat: multiple select delete --- src/commands/explore.rs | 21 +++++++++++++++------ src/skim/explore.rs | 14 +++++--------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/commands/explore.rs b/src/commands/explore.rs index 1781805..7ed3af0 100644 --- a/src/commands/explore.rs +++ b/src/commands/explore.rs @@ -147,13 +147,22 @@ pub(crate) async fn exec( } Some(Action::Remove(removed)) => { - let next = match remove(db.clone(), removed.clone(), true).await { - Ok(true) => vec![], - Ok(false) => vec![removed], - Err(err) => { - eprintln!("remove error: {:?}", err); - vec![removed] + let mut success = true; + for note in removed.clone() { + match remove(db.clone(), note.clone(), true).await { + Ok(true) => {}, + Ok(false) => { success = false;}, + Err(err) => { + eprintln!("remove error: {:?}", err); + success = false; + } } + + } + + let next = match success { + true => vec![], + false => removed, }; list = next; } diff --git a/src/skim/explore.rs b/src/skim/explore.rs index 804322e..e21a625 100644 --- a/src/skim/explore.rs +++ b/src/skim/explore.rs @@ -34,7 +34,7 @@ pub enum Action { Forward, Widen, Rename(Note), - Remove(Note), + Remove(Vec), CreateLinkedFrom(Note), Surf(Note), Checkmark(Note), @@ -281,14 +281,10 @@ impl Iteration { } keymap::explore::Action::RemoveNote => { - if let Some(item) = selected_items.first() { - Ok(Out { - action: Action::Remove(item.clone()), - next_items: vec![], - }) - } else { - Err(anyhow::anyhow!("no item selected")) - } + Ok(Out { + action: Action::Remove(selected_items), + next_items: vec![], + }) } keymap::explore::Action::CreateAutolinkedNote => {