diff --git a/app/assets/javascripts/views/editor/editor-view.pug b/app/assets/javascripts/views/editor/editor-view.pug index 23d748efc..a19b4c0fe 100644 --- a/app/assets/javascripts/views/editor/editor-view.pug +++ b/app/assets/javascripts/views/editor/editor-view.pug @@ -1,11 +1,11 @@ #editor-column.section.editor.sn-component(aria-label='Note') protected-note-panel.h-full.flex.justify-center.items-center( - ng-if='self.note.protected && !self.state.showEditor' + ng-if='self.state.showProtectedWarning' app-state='self.appState' on-view-note='self.dismissProtectedWarning()' ) .flex-grow.flex.flex-col( - ng-if='self.state.showEditor' + ng-if='!self.state.showProtectedWarning' ) .sn-component .sk-app-bar.no-edges( diff --git a/app/assets/javascripts/views/editor/editor_view.ts b/app/assets/javascripts/views/editor/editor_view.ts index ee841f627..7af6638b2 100644 --- a/app/assets/javascripts/views/editor/editor_view.ts +++ b/app/assets/javascripts/views/editor/editor_view.ts @@ -80,7 +80,7 @@ type EditorState = { textareaUnloading: boolean /** Fields that can be directly mutated by the template */ mutable: any - showEditor: boolean + showProtectedWarning: boolean } type EditorValues = { @@ -225,7 +225,7 @@ class EditorViewCtrl extends PureViewCtrl { mutable: { tagsString: '' }, - showEditor: false, + showProtectedWarning: false, } as EditorState; } @@ -275,7 +275,7 @@ class EditorViewCtrl extends PureViewCtrl { async handleEditorNoteChange() { this.cancelPendingSetStatus(); const note = this.editor.note; - const showEditor = !note.protected; + const showProtectedWarning = note.protected && !this.application.hasProtectionSources(); await this.setState({ showActionsMenu: false, showOptionsMenu: false, @@ -283,7 +283,7 @@ class EditorViewCtrl extends PureViewCtrl { showHistoryMenu: false, altKeyDown: false, noteStatus: undefined, - showEditor, + showProtectedWarning, }); this.editorValues.title = note.title; this.editorValues.text = note.text; @@ -292,14 +292,14 @@ class EditorViewCtrl extends PureViewCtrl { this.reloadPreferences(); this.reloadStackComponents(); this.reloadNoteTagsComponent(); - if (note.safeText().length === 0 && showEditor) { + if (note.safeText().length === 0 && !showProtectedWarning) { this.focusTitle(); } } async dismissProtectedWarning() { await this.setState({ - showEditor: true + showProtectedWarning: false }); this.focusTitle(); } @@ -730,13 +730,9 @@ class EditorViewCtrl extends PureViewCtrl { } else { const note = await this.application.protectNote(this.note); if (note?.protected && !this.application.hasProtectionSources()) { - if (await confirmDialog({ - text: Strings.protectingNoteWithoutProtectionSources, - confirmButtonText: Strings.openAccountMenu, - confirmButtonStyle: 'info', - })) { - this.appState.accountMenu.setShow(true); - } + this.setState({ + showProtectedWarning: true + }); } } }