fix: timing of editor component view unloading
This commit is contained in:
@@ -189,14 +189,36 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
|||||||
this.editorValues.text = note.text;
|
this.editorValues.text = note.text;
|
||||||
this.reloadTagsString();
|
this.reloadTagsString();
|
||||||
}
|
}
|
||||||
|
if (note.lastSyncBegan && note.lastSyncEnd) {
|
||||||
|
if (note.lastSyncBegan!.getTime() > note.lastSyncEnd!.getTime()) {
|
||||||
|
this.showSavingStatus()
|
||||||
|
} else if (note.lastSyncEnd!.getTime() > note.lastSyncBegan!.getTime()) {
|
||||||
|
this.showAllChangesSavedStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.removeComponentGroupObserver = this.componentGroup.addChangeObserver(() => {
|
this.removeComponentGroupObserver = this.componentGroup.addChangeObserver(
|
||||||
this.setEditorState({
|
async () => {
|
||||||
activeEditorComponent: this.componentGroup.activeComponentForArea(ComponentArea.Editor),
|
const currentEditor = this.activeEditorComponent;
|
||||||
activeTagsComponent: this.componentGroup.activeComponentForArea(ComponentArea.NoteTags),
|
const newEditor = this.componentGroup.activeComponentForArea(ComponentArea.Editor);
|
||||||
activeStackComponents: this.componentGroup.activeComponentsForArea(ComponentArea.EditorStack)
|
if (currentEditor && newEditor && currentEditor.uuid !== newEditor.uuid) {
|
||||||
})
|
/** Unload current component view so that we create a new one,
|
||||||
})
|
* then change the active editor */
|
||||||
|
await this.setEditorState({
|
||||||
|
editorComponentUnloading: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await this.setEditorState({
|
||||||
|
activeEditorComponent: newEditor,
|
||||||
|
activeTagsComponent: this.componentGroup.activeComponentForArea(ComponentArea.NoteTags),
|
||||||
|
activeStackComponents: this.componentGroup.activeComponentsForArea(ComponentArea.EditorStack)
|
||||||
|
})
|
||||||
|
/** Stop unloading, if we were already unloading */
|
||||||
|
await this.setEditorState({
|
||||||
|
editorComponentUnloading: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
@@ -236,14 +258,10 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
|||||||
this.setEditorState({ syncTakingTooLong: true });
|
this.setEditorState({ syncTakingTooLong: true });
|
||||||
} else if (eventName === ApplicationEvent.CompletedSync) {
|
} else if (eventName === ApplicationEvent.CompletedSync) {
|
||||||
this.setEditorState({ syncTakingTooLong: false });
|
this.setEditorState({ syncTakingTooLong: false });
|
||||||
if (this.note.dirty) {
|
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. */
|
||||||
} else {
|
if (!this.note.dirty && isInErrorState) {
|
||||||
const saved = this.note.lastSyncEnd! > this.note.lastSyncBegan!;
|
this.showAllChangesSavedStatus();
|
||||||
const isInErrorState = this.getState().saveError;
|
|
||||||
if (isInErrorState || saved) {
|
|
||||||
this.showAllChangesSavedStatus();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (eventName === ApplicationEvent.FailedSync) {
|
} else if (eventName === ApplicationEvent.FailedSync) {
|
||||||
/**
|
/**
|
||||||
@@ -310,20 +328,7 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
|||||||
return { editor: associatedEditor, changed: false };
|
return { editor: associatedEditor, changed: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.activeEditorComponent) {
|
await this.componentGroup.activateComponent(associatedEditor);
|
||||||
/** No existing editor set, set this one */
|
|
||||||
await this.componentGroup.activateComponent(associatedEditor);
|
|
||||||
} else {
|
|
||||||
/** Only remaining condition: editor is being changed. Unload current component
|
|
||||||
* view so that we create a new one, then change the active editor */
|
|
||||||
await this.setEditorState({
|
|
||||||
editorComponentUnloading: true
|
|
||||||
});
|
|
||||||
await this.componentGroup.activateComponent(associatedEditor);
|
|
||||||
await this.setEditorState({
|
|
||||||
editorComponentUnloading: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return { editor: associatedEditor, changed: true };
|
return { editor: associatedEditor, changed: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,7 +518,6 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.showSavingStatus();
|
|
||||||
await this.application.changeItem(note.uuid, (mutator) => {
|
await this.application.changeItem(note.uuid, (mutator) => {
|
||||||
const noteMutator = mutator as NoteMutator;
|
const noteMutator = mutator as NoteMutator;
|
||||||
if (customMutate) {
|
if (customMutate) {
|
||||||
@@ -539,7 +543,7 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
|||||||
: SAVE_TIMEOUT_DEBOUNCE;
|
: SAVE_TIMEOUT_DEBOUNCE;
|
||||||
this.saveTimeout = this.$timeout(() => {
|
this.saveTimeout = this.$timeout(() => {
|
||||||
this.application.sync();
|
this.application.sync();
|
||||||
if(closeAfterSync) {
|
if (closeAfterSync) {
|
||||||
this.appState.closeEditor(this.editor);
|
this.appState.closeEditor(this.editor);
|
||||||
}
|
}
|
||||||
}, syncDebouceMs);
|
}, syncDebouceMs);
|
||||||
@@ -1081,14 +1085,6 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
|||||||
const tag = this.application.findItem(data.item.uuid) as SNTag;
|
const tag = this.application.findItem(data.item.uuid) as SNTag;
|
||||||
this.removeTag(tag);
|
this.removeTag(tag);
|
||||||
}
|
}
|
||||||
else if (action === ComponentAction.SaveItems) {
|
|
||||||
const includesNote = data.items.map((item: RawPayload) => {
|
|
||||||
return item.uuid;
|
|
||||||
}).includes(this.note.uuid);
|
|
||||||
if (includesNote) {
|
|
||||||
this.showSavingStatus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1106,8 +1102,8 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
|||||||
/** component.active is a persisted state. So if we download a stack component
|
/** component.active is a persisted state. So if we download a stack component
|
||||||
* whose .active is true, it doesn't mean it was explicitely activated by us. So
|
* whose .active is true, it doesn't mean it was explicitely activated by us. So
|
||||||
* we need to do that here. */
|
* we need to do that here. */
|
||||||
for(const component of components) {
|
for (const component of components) {
|
||||||
if(component.active) {
|
if (component.active) {
|
||||||
this.componentGroup.activateComponent(component);
|
this.componentGroup.activateComponent(component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,6 +202,13 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
[ContentType.Note],
|
[ContentType.Note],
|
||||||
async (items) => {
|
async (items) => {
|
||||||
const notes = items as SNNote[];
|
const notes = items as SNNote[];
|
||||||
|
/** Note has changed values, reset its flags */
|
||||||
|
for (const note of notes) {
|
||||||
|
if (note.deleted) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this.loadFlagsForNote(note);
|
||||||
|
}
|
||||||
/** If a note changes, it will be queried against the existing filter;
|
/** If a note changes, it will be queried against the existing filter;
|
||||||
* we dont need to reload display options */
|
* we dont need to reload display options */
|
||||||
await this.reloadNotes();
|
await this.reloadNotes();
|
||||||
@@ -214,13 +221,6 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
} else {
|
} else {
|
||||||
this.selectFirstNote();
|
this.selectFirstNote();
|
||||||
}
|
}
|
||||||
/** Note has changed values, reset its flags */
|
|
||||||
for (const note of notes) {
|
|
||||||
if (note.deleted) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
this.loadFlagsForNote(note);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -332,11 +332,6 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const notes = this.application.getDisplayableItems(ContentType.Note) as SNNote[];
|
const notes = this.application.getDisplayableItems(ContentType.Note) as SNNote[];
|
||||||
for (const note of notes) {
|
|
||||||
if (note.errorDecrypting) {
|
|
||||||
this.loadFlagsForNote(note);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await this.setNotesState({
|
await this.setNotesState({
|
||||||
notes: notes,
|
notes: notes,
|
||||||
renderedNotes: notes.slice(0, this.notesToDisplay)
|
renderedNotes: notes.slice(0, this.notesToDisplay)
|
||||||
@@ -561,7 +556,6 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.noteFlags[note.uuid] = flags;
|
this.noteFlags[note.uuid] = flags;
|
||||||
return flags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
displayableNotes() {
|
displayableNotes() {
|
||||||
|
|||||||
883
dist/javascripts/app.js
vendored
883
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