From e74f12e266e10e6fce36b4d56acedb877fd87f08 Mon Sep 17 00:00:00 2001 From: thecodrr Date: Sat, 14 Mar 2020 09:36:47 +0500 Subject: [PATCH] fix: #105 --- apps/web/src/common/selectionoptions.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/apps/web/src/common/selectionoptions.js b/apps/web/src/common/selectionoptions.js index 31b5d3ec6..7466cd07b 100644 --- a/apps/web/src/common/selectionoptions.js +++ b/apps/web/src/common/selectionoptions.js @@ -6,6 +6,7 @@ import { store as editorStore } from "../stores/editor-store"; import { db } from "./index"; import { showMoveNoteDialog } from "../components/dialogs/movenotedialog"; import { confirm } from "../components/dialogs/confirm"; +import { showPasswordDialog } from "../components/dialogs/passworddialog"; function createOption(icon, onClick) { return { @@ -29,8 +30,24 @@ const DeleteOption = createOption(Icon.Trash2, async function(state) { const item = state.selectedItems[0]; var isAnyNoteOpened = false; const editorState = editorStore.getState(); - const items = state.selectedItems.map(item => { + const items = state.selectedItems.map(async item => { if (item.id === editorState.session.id) isAnyNoteOpened = true; + if (item.locked) { + if ( + !(await confirm( + Icon.Trash2, + "Delete", + "This is a locked note. Are you sure you want to delete it?" + )) || + !(await showPasswordDialog("unlock_note", password => { + return db.vault + .unlock(password) + .then(() => true) + .catch(() => false); + })) + ) + return 0; + } return item.id; });