Added caching of loaded editor instance

This commit is contained in:
Tom Moor
2019-01-19 01:31:34 -08:00
parent 72d8abe069
commit bfd32843ff
7 changed files with 31 additions and 3 deletions

View File

@@ -41,6 +41,7 @@ import Revision from 'models/Revision';
import schema from './schema';
let EditorImport;
const AUTOSAVE_DELAY = 3000;
const IS_DIRTY_DELAY = 500;
const MARK_AS_VIEWED_AFTER = 3000;
@@ -69,7 +70,7 @@ class DocumentScene extends React.Component<Props> {
viewTimeout: TimeoutID;
getEditorText: () => string;
@observable editorComponent;
@observable editorComponent = EditorImport;
@observable document: ?Document;
@observable revision: ?Revision;
@observable newDocument: ?Document;
@@ -184,8 +185,11 @@ class DocumentScene extends React.Component<Props> {
};
loadEditor = async () => {
const EditorImport = await import('./components/Editor');
this.editorComponent = EditorImport.default;
if (this.editorComponent) return;
const Imported = await import('./components/Editor');
EditorImport = Imported.default;
this.editorComponent = EditorImport;
};
get isEditing() {