diff --git a/app/assets/javascripts/strings.ts b/app/assets/javascripts/strings.ts index c8782ae29..25232bc9c 100644 --- a/app/assets/javascripts/strings.ts +++ b/app/assets/javascripts/strings.ts @@ -124,4 +124,6 @@ export const Strings = { : 'password manager'; return `Your keys are currently stored in your operating system's ${keychainName}. Adding a passcode prevents even your operating system from reading them.`; }, + protectingNoteWithoutProtectionSources: 'Access to this note will not be restricted until you set up a passcode or account.', + openAccountMenu: 'Open Account Menu' }; diff --git a/app/assets/javascripts/views/editor/editor_view.ts b/app/assets/javascripts/views/editor/editor_view.ts index c0f67f836..5fca2e50e 100644 --- a/app/assets/javascripts/views/editor/editor_view.ts +++ b/app/assets/javascripts/views/editor/editor_view.ts @@ -1,4 +1,4 @@ -import { STRING_ARCHIVE_LOCKED_ATTEMPT, STRING_SAVING_WHILE_DOCUMENT_HIDDEN, STRING_UNARCHIVE_LOCKED_ATTEMPT } from './../../strings'; +import { Strings, STRING_ARCHIVE_LOCKED_ATTEMPT, STRING_SAVING_WHILE_DOCUMENT_HIDDEN, STRING_UNARCHIVE_LOCKED_ATTEMPT } from './../../strings'; import { Editor } from '@/ui_models/editor'; import { WebApplication } from '@/ui_models/application'; import { PanelPuppet, WebDirective } from '@/types'; @@ -713,15 +713,23 @@ class EditorViewCtrl extends PureViewCtrl { ); } - toggleProtectNote() { - this.saveNote( - true, - false, - true, + async toggleProtectNote() { + const note = await this.application.changeAndSaveItem( + this.note.uuid, (mutator) => { mutator.protected = !this.note.protected; - } + }, + false ); + if (note?.protected && !this.application.hasProtectionSources()) { + if (await confirmDialog({ + text: Strings.protectingNoteWithoutProtectionSources, + confirmButtonText: Strings.openAccountMenu, + confirmButtonStyle: 'info', + })) { + this.appState.accountMenu.setShow(true); + } + } } toggleNotePreview() {