diff --git a/app/assets/javascripts/strings.ts b/app/assets/javascripts/strings.ts index f9847de89..e07fe6817 100644 --- a/app/assets/javascripts/strings.ts +++ b/app/assets/javascripts/strings.ts @@ -40,6 +40,8 @@ export const STRING_UNARCHIVE_LOCKED_ATTEMPT = "This note is locked. If you'd like to archive it, unlock it, and try again."; export const STRING_DELETE_LOCKED_ATTEMPT = "This note is locked. If you'd like to delete it, unlock it, and try again."; +export const STRING_EDIT_LOCKED_ATTEMPT = + "This note is locked. If you'd like to edit its options, unlock it, and try again."; export function StringDeleteNote(title: string, permanently: boolean) { return permanently ? `Are you sure you want to permanently delete ${title}?` diff --git a/app/assets/javascripts/views/editor/editor_view.ts b/app/assets/javascripts/views/editor/editor_view.ts index c70f6f1bd..70227a1da 100644 --- a/app/assets/javascripts/views/editor/editor_view.ts +++ b/app/assets/javascripts/views/editor/editor_view.ts @@ -34,6 +34,7 @@ import { STRING_ELLIPSES, STRING_DELETE_PLACEHOLDER_ATTEMPT, STRING_DELETE_LOCKED_ATTEMPT, + STRING_EDIT_LOCKED_ATTEMPT, StringDeleteNote, StringEmptyTrash, } from '@/strings'; @@ -202,9 +203,12 @@ class EditorViewCtrl extends PureViewCtrl { if (!this.editorValues.text) { this.editorValues.text = note.text; } - if (note.lastSyncBegan) { + if (note.lastSyncBegan || note.dirty) { if (note.lastSyncEnd) { - if (note.lastSyncBegan!.getTime() > note.lastSyncEnd!.getTime()) { + if ( + note.dirty || + note.lastSyncBegan!.getTime() > note.lastSyncEnd!.getTime() + ) { this.showSavingStatus(); } else if ( note.lastSyncEnd!.getTime() > note.lastSyncBegan!.getTime() @@ -305,6 +309,9 @@ class EditorViewCtrl extends PureViewCtrl { this.reloadPreferences(); this.reloadStackComponents(); this.reloadNoteTagsComponent(); + if (note.dirty) { + this.showSavingStatus(); + } if (note.safeText().length === 0 && !showProtectedWarning) { this.focusTitle(); } @@ -412,6 +419,10 @@ class EditorViewCtrl extends PureViewCtrl { if (this.appState.getActiveEditor()?.isTemplateNote) { await this.appState.getActiveEditor().insertTemplatedNote(); } + if (this.note.locked) { + this.application.alertService.alert(STRING_EDIT_LOCKED_ATTEMPT); + return; + } if (!component) { if (!this.note.prefersPlainEditor) { await this.application.changeItem(this.note.uuid, (mutator) => {