mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 12:12:54 +01:00
fix: unable to delete multiple items with del key
(fixes streetwriters/notesnook#429)
This commit is contained in:
@@ -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[]) {
|
||||
|
||||
@@ -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={{
|
||||
|
||||
Reference in New Issue
Block a user