diff --git a/apps/web/src/components/note/index.tsx b/apps/web/src/components/note/index.tsx index 883001128..b59c00ef1 100644 --- a/apps/web/src/components/note/index.tsx +++ b/apps/web/src/components/note/index.tsx @@ -369,10 +369,9 @@ const menuItems: (note: any, items?: any[]) => MenuItem[] = ( onClick: async () => { const { unlock, lock } = store.get(); if (!note.locked) { - await lock(note.id); - showToast("success", "Note locked successfully!"); - } else { - await unlock(note.id); + if (await lock(note.id)) + showToast("success", "Note locked successfully!"); + } else if (await unlock(note.id)) { showToast("success", "Note unlocked successfully!"); } }, diff --git a/apps/web/src/stores/note-store.js b/apps/web/src/stores/note-store.js index bc923f6d7..78fcb6e20 100644 --- a/apps/web/src/stores/note-store.js +++ b/apps/web/src/stores/note-store.js @@ -123,10 +123,11 @@ class NoteStore extends BaseStore { }; lock = async (id) => { - await Vault.lockNote(id); + if (!(await Vault.lockNote(id))) return false; this.refreshItem(id); if (editorStore.get().session.id === id) await editorStore.openSession(id, true); + return true; }; readonly = async (id) => {