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