fix: editor status after changing note
This commit is contained in:
@@ -75,10 +75,10 @@ export class Editor {
|
||||
/**
|
||||
* Register to be notified when the editor's note changes.
|
||||
*/
|
||||
public onNoteChange(onNoteChange: () => void) {
|
||||
this._onNoteChange = onNoteChange;
|
||||
public onNoteChange(callback: () => void) {
|
||||
this._onNoteChange = callback;
|
||||
if (this.note) {
|
||||
onNoteChange();
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,10 +86,8 @@ export class Editor {
|
||||
* Register to be notified when the editor's note's values change
|
||||
* (and thus a new object reference is created)
|
||||
*/
|
||||
public onNoteValueChange(
|
||||
onNoteValueChange: (note: SNNote, source?: PayloadSource) => void
|
||||
) {
|
||||
this._onNoteValueChange = onNoteValueChange;
|
||||
public onNoteValueChange(callback: (note: SNNote, source?: PayloadSource) => void) {
|
||||
this._onNoteValueChange = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -106,8 +106,10 @@ export class PureViewCtrl {
|
||||
await this.onAppStart();
|
||||
} else if (eventName === ApplicationEvent.Launched) {
|
||||
await this.onAppLaunch();
|
||||
} else if (eventName === ApplicationEvent.CompletedSync) {
|
||||
this.onAppSync();
|
||||
} else if (eventName === ApplicationEvent.CompletedIncrementalSync) {
|
||||
this.onAppIncrementalSync();
|
||||
} else if (eventName === ApplicationEvent.CompletedFullSync) {
|
||||
this.onAppFullSync();
|
||||
} else if (eventName === ApplicationEvent.KeyStatusChanged) {
|
||||
this.onAppKeyChange();
|
||||
}
|
||||
@@ -131,7 +133,11 @@ export class PureViewCtrl {
|
||||
/** Optional override */
|
||||
}
|
||||
|
||||
onAppSync() {
|
||||
onAppIncrementalSync() {
|
||||
/** Optional override */
|
||||
}
|
||||
|
||||
onAppFullSync() {
|
||||
/** Optional override */
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ class ApplicationViewCtrl extends PureViewCtrl {
|
||||
"Syncing..."
|
||||
);
|
||||
}
|
||||
} else if (eventName === ApplicationEvent.CompletedSync) {
|
||||
} else if (eventName === ApplicationEvent.CompletedFullSync) {
|
||||
if (!this.completedInitialSync) {
|
||||
this.syncStatus = this.application!.getStatusService().removeStatus(this.syncStatus);
|
||||
this.completedInitialSync = true;
|
||||
|
||||
@@ -38,7 +38,7 @@ const NOTE_PREVIEW_CHAR_LIMIT = 80;
|
||||
const MINIMUM_STATUS_DURATION = 400;
|
||||
const SAVE_TIMEOUT_DEBOUNCE = 350;
|
||||
const SAVE_TIMEOUT_NO_DEBOUNCE = 100;
|
||||
const EDITOR_DEBOUNCE = 200;
|
||||
const EDITOR_DEBOUNCE = 100;
|
||||
|
||||
const ElementIds = {
|
||||
NoteTextEditor: 'note-text-editor',
|
||||
@@ -71,6 +71,8 @@ type EditorState = {
|
||||
syncTakingTooLong: boolean
|
||||
showExtensions: boolean
|
||||
showOptionsMenu: boolean
|
||||
showEditorMenu: boolean
|
||||
showSessionHistory: boolean
|
||||
altKeyDown: boolean
|
||||
spellcheck: boolean
|
||||
/** Setting to false then true will allow the current editor component-view to be destroyed
|
||||
@@ -256,7 +258,7 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
||||
onAppEvent(eventName: ApplicationEvent) {
|
||||
if (eventName === ApplicationEvent.HighLatencySync) {
|
||||
this.setEditorState({ syncTakingTooLong: true });
|
||||
} else if (eventName === ApplicationEvent.CompletedSync) {
|
||||
} else if (eventName === ApplicationEvent.CompletedFullSync) {
|
||||
this.setEditorState({ syncTakingTooLong: false });
|
||||
const isInErrorState = this.getState().saveError;
|
||||
/** if we're still dirty, don't change status, a sync is likely upcoming. */
|
||||
@@ -293,22 +295,25 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
||||
}
|
||||
|
||||
async handleEditorNoteChange() {
|
||||
const note = this.editor.note;
|
||||
this.cancelPendingSetStatus();
|
||||
await this.setEditorState({
|
||||
showExtensions: false,
|
||||
showOptionsMenu: false,
|
||||
showEditorMenu: false,
|
||||
showSessionHistory: false,
|
||||
altKeyDown: false,
|
||||
noteStatus: undefined
|
||||
});
|
||||
const note = this.editor.note;
|
||||
this.editorValues.title = note.title;
|
||||
this.editorValues.text = note.text;
|
||||
await this.reloadComponentEditorState();
|
||||
this.reloadTagsString();
|
||||
this.reloadPreferences();
|
||||
this.reloadComponentContext();
|
||||
if (note.safeText().length === 0) {
|
||||
this.focusTitle();
|
||||
}
|
||||
this.reloadComponentContext();
|
||||
}
|
||||
|
||||
async reloadComponentEditorState() {
|
||||
@@ -603,6 +608,12 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
||||
}, waitForMs);
|
||||
}
|
||||
|
||||
cancelPendingSetStatus() {
|
||||
if (this.statusTimeout) {
|
||||
this.$timeout.cancel(this.statusTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
contentChanged() {
|
||||
this.saveNote(
|
||||
false,
|
||||
|
||||
@@ -184,7 +184,7 @@ class FooterViewCtrl extends PureViewCtrl {
|
||||
this.setState({
|
||||
outOfSync: false
|
||||
});
|
||||
} else if (eventName === ApplicationEvent.CompletedSync) {
|
||||
} else if (eventName === ApplicationEvent.CompletedFullSync) {
|
||||
if (!this.didCheckForOffline) {
|
||||
this.didCheckForOffline = true;
|
||||
if (this.offline && this.application!.getNoteCount() === 0) {
|
||||
|
||||
@@ -157,7 +157,7 @@ class NotesViewCtrl extends PureViewCtrl {
|
||||
if (eventName === ApplicationEvent.SignedIn) {
|
||||
this.appState.closeAllEditors();
|
||||
this.selectFirstNote();
|
||||
} else if (eventName === ApplicationEvent.CompletedSync) {
|
||||
} else if (eventName === ApplicationEvent.CompletedFullSync) {
|
||||
this.getMostValidNotes().then((notes) => {
|
||||
if (notes.length === 0) {
|
||||
this.createPlaceholderNote();
|
||||
|
||||
@@ -98,8 +98,8 @@ class TagsViewCtrl extends PureViewCtrl {
|
||||
}
|
||||
|
||||
/** @override */
|
||||
onAppSync() {
|
||||
super.onAppSync();
|
||||
onAppIncrementalSync() {
|
||||
super.onAppIncrementalSync();
|
||||
this.reloadNoteCounts();
|
||||
}
|
||||
|
||||
@@ -166,12 +166,6 @@ class TagsViewCtrl extends PureViewCtrl {
|
||||
super.onAppEvent(eventName);
|
||||
if (eventName === ApplicationEvent.LocalDataIncrementalLoad) {
|
||||
this.reloadNoteCounts();
|
||||
} else if (eventName === ApplicationEvent.SyncStatusChanged) {
|
||||
const syncStatus = this.application.getSyncStatus();
|
||||
const stats = syncStatus.getStats();
|
||||
if (stats.downloadCount > 0) {
|
||||
this.reloadNoteCounts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +181,7 @@ class TagsViewCtrl extends PureViewCtrl {
|
||||
for (const tag of allTags) {
|
||||
if (tag.isSmartTag()) {
|
||||
/** Other smart tags do not contain counts */
|
||||
if(tag.isAllTag) {
|
||||
if (tag.isAllTag) {
|
||||
const notes = this.application.notesMatchingSmartTag(tag as SNSmartTag)
|
||||
.filter((note) => {
|
||||
return !note.archived && !note.trashed;
|
||||
|
||||
90
dist/javascripts/app.js
vendored
90
dist/javascripts/app.js
vendored
File diff suppressed because one or more lines are too long
2
dist/javascripts/app.js.map
vendored
2
dist/javascripts/app.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user