From 807bd683b798ea547593f37f7ee272fc4a0f0e13 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Mon, 29 Jan 2024 15:36:01 +0500 Subject: [PATCH] web: do not show success prompt on unlock cancel --- apps/web/src/components/note/index.tsx | 7 +++---- apps/web/src/stores/note-store.js | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) 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) => {