fix: more accurate saving status + dont allow editor change while note is locked
This commit is contained in:
@@ -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}?`
|
||||
|
||||
@@ -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<unknown, EditorState> {
|
||||
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<unknown, EditorState> {
|
||||
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<unknown, EditorState> {
|
||||
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) => {
|
||||
|
||||
Reference in New Issue
Block a user