Skip to content

Commit

Permalink
feat: multiple select delete
Browse files Browse the repository at this point in the history
  • Loading branch information
dj8yf0μl committed Sep 1, 2023
1 parent dd65aea commit 6d026b3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
21 changes: 15 additions & 6 deletions src/commands/explore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
14 changes: 5 additions & 9 deletions src/skim/explore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub enum Action {
Forward,
Widen,
Rename(Note),
Remove(Note),
Remove(Vec<Note>),
CreateLinkedFrom(Note),
Surf(Note),
Checkmark(Note),
Expand Down Expand Up @@ -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 => {
Expand Down

0 comments on commit 6d026b3

Please sign in to comment.