mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 04:00:59 +01:00
web: add support for moving locked notes to trash (#4134)
* web: added support for single/multi trash notes * web: show error when trying to preview a locked note in trash --------- Co-authored-by: Abdullah Atta <abdullahatta@streetwriters.co>
This commit is contained in:
@@ -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;
|
||||
});
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.");
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user