diff --git a/apps/web/src/common/multi-select.ts b/apps/web/src/common/multi-select.ts index 348bbcfd3..cc9ba0d0c 100644 --- a/apps/web/src/common/multi-select.ts +++ b/apps/web/src/common/multi-select.ts @@ -35,20 +35,11 @@ type Item = { }; async function moveNotesToTrash(notes: Item[], confirm = true) { - const item = notes[0]; if (confirm && !(await showMultiDeleteConfirmation(notes.length))) return; - - if (notes.length === 1) { - if ( - item.locked && - !(await Vault.unlockNote(item.id, "unlock_and_delete_note")) - ) - return; - item.locked = false; - } + if (notes.some((n) => n.locked) && !(await Vault.unlockVault())) return; const items = notes.map((item) => { - if (item.locked || db.monographs?.isPublished(item.id)) return 0; + if (db.monographs?.isPublished(item.id)) return 0; return item.id; }); diff --git a/apps/web/src/components/note/index.tsx b/apps/web/src/components/note/index.tsx index 95acf075f..c42dcf61f 100644 --- a/apps/web/src/components/note/index.tsx +++ b/apps/web/src/components/note/index.tsx @@ -539,7 +539,7 @@ const menuItems: (note: any, items?: any[]) => MenuItem[] = ( icon: Trash.path, isDisabled: items.length === 1 - ? db.monographs?.isPublished(note.id) || note.locked + ? db.monographs?.isPublished(note.id) : items.some((item) => !db.notes?.note(item.id).synced()), onClick: () => Multiselect.moveNotesToTrash(items, items.length > 1), multiSelect: true diff --git a/apps/web/src/components/trash-item/index.tsx b/apps/web/src/components/trash-item/index.tsx index 8db56fd72..b6b5351d2 100644 --- a/apps/web/src/components/trash-item/index.tsx +++ b/apps/web/src/components/trash-item/index.tsx @@ -59,7 +59,9 @@ function TrashItem(props: TrashItemProps) { menuItems={menuItems} onClick={() => { if (item.itemType === "note") - hashNavigate(`/notes/${item.id}/edit`, { replace: true }); + !item.locked + ? hashNavigate(`/notes/${item.id}/edit`, { replace: true }) + : showToast("error", "Locked notes cannot be previewed in trash."); }} /> );