fix: debounce editor reloading to handle fast fire
This commit is contained in:
@@ -21,7 +21,7 @@ import {
|
|||||||
ItemMutator,
|
ItemMutator,
|
||||||
ProposedSecondsToDeferUILevelSessionExpirationDuringActiveInteraction,
|
ProposedSecondsToDeferUILevelSessionExpirationDuringActiveInteraction,
|
||||||
} from '@standardnotes/snjs';
|
} from '@standardnotes/snjs';
|
||||||
import { isDesktopApplication } from '@/utils';
|
import { debounce, isDesktopApplication } from '@/utils';
|
||||||
import { KeyboardModifier, KeyboardKey } from '@/services/ioService';
|
import { KeyboardModifier, KeyboardKey } from '@/services/ioService';
|
||||||
import template from './editor-view.pug';
|
import template from './editor-view.pug';
|
||||||
import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl';
|
import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl';
|
||||||
@@ -130,6 +130,10 @@ export class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
|
|||||||
this.onEditorLoad = () => {
|
this.onEditorLoad = () => {
|
||||||
this.application.getDesktopService().redoSearch();
|
this.application.getDesktopService().redoSearch();
|
||||||
};
|
};
|
||||||
|
this.debounceReloadEditorComponent = debounce(
|
||||||
|
this.debounceReloadEditorComponent.bind(this),
|
||||||
|
25
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit() {
|
deinit() {
|
||||||
@@ -180,10 +184,6 @@ export class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
|
|||||||
|
|
||||||
this.reloadPreferences();
|
this.reloadPreferences();
|
||||||
|
|
||||||
if (this.note.dirty) {
|
|
||||||
this.showSavingStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.editor.isTemplateNote) {
|
if (this.editor.isTemplateNote) {
|
||||||
this.$timeout(() => {
|
this.$timeout(() => {
|
||||||
this.focusTitle();
|
this.focusTitle();
|
||||||
@@ -383,7 +383,7 @@ export class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
|
|||||||
}
|
}
|
||||||
if (!this.note) return;
|
if (!this.note) return;
|
||||||
await this.reloadStackComponents();
|
await this.reloadStackComponents();
|
||||||
await this.reloadEditorComponent();
|
this.debounceReloadEditorComponent();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -410,6 +410,14 @@ export class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calling reloadEditorComponent successively without waiting for state to settle
|
||||||
|
* can result in componentViewers being dealloced twice
|
||||||
|
*/
|
||||||
|
debounceReloadEditorComponent() {
|
||||||
|
this.reloadEditorComponent();
|
||||||
|
}
|
||||||
|
|
||||||
private async reloadEditorComponent() {
|
private async reloadEditorComponent() {
|
||||||
const newEditor = this.application.componentManager.editorForNote(
|
const newEditor = this.application.componentManager.editorForNote(
|
||||||
this.note
|
this.note
|
||||||
|
|||||||
Reference in New Issue
Block a user