Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: unable to delete multiple items with del key (fixes streetwriters/notesnook#429)

thecodrrd509defe552d
diff --git a/apps/web/src/common/multi-select.ts b/apps/web/src/common/multi-select.ts
index 2447d604c..a364f768a 100644
--- a/apps/web/src/common/multi-select.ts
+++ b/apps/web/src/common/multi-select.ts
@@ -10,10 +10,9 @@ import { TaskManager } from "./task-manager";
async function moveNotesToTrash(notes: any[]) {
const item = notes[0];
- const isMultiselect = notes.length > 1;
- if (isMultiselect) {
- if (!(await showMultiDeleteConfirmation(notes.length))) return;
- } else {
+ if (!(await showMultiDeleteConfirmation(notes.length))) return;
+
+ if (notes.length === 1) {
if (
item.locked &&
!(await Vault.unlockNote(item.id, "unlock_and_delete_note"))
@@ -38,11 +37,7 @@ async function moveNotesToTrash(notes: any[]) {
},
});
- if (isMultiselect) {
- showToast("success", `${items.length} notes moved to trash`);
- } else {
- showItemDeletedToast(item);
- }
+ showToast("success", `${items.length} notes moved to trash`);
}
async function moveNotebooksToTrash(notebooks: any[]) {
diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.js
index 1fa6b8f11..b1c96aecf 100644
--- a/apps/web/src/components/note/index.js
+++ b/apps/web/src/components/note/index.js
@@ -15,6 +15,7 @@ import IconTag from "../icon-tag";
import { COLORS } from "../../common/constants";
import { exportNotes } from "../../common/export";
import { Multiselect } from "../../common/multi-select";
+import { store as selectionStore } from "../../stores/selection-store";
function Note(props) {
const { tags, notebook, item, index, context, date } = props;
@@ -46,14 +47,10 @@ function Note(props) {
index={index}
onKeyPress={async (e) => {
if (e.key === "Delete") {
- await confirm({
- title: "Delete note?",
- message:
- "This item will be kept in your Trash for 7 days after which it will be permanently removed",
- noText: "No",
- yesText: "Yes",
- yesAction: () => Multiselect.moveNotesToTrash([item]),
- });
+ let selectedItems = selectionStore
+ .get()
+ .selectedItems.filter((i) => i.type === item.type && i !== item);
+ await Multiselect.moveNotesToTrash([item, ...selectedItems]);
}
}}
colors={{