From 3b41435e9bd1be242c1a024259e356d28a293143 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 8 Mar 2022 10:22:20 +0100 Subject: [PATCH] refactor: extract logic into computed Also rename `initialLoading` in `EditorWrapper` to `contentLoaded`. This flag is set during the `initialLoading` state change. It does indicates that the loading happened Use the past tense to indicate that. The editor wrapper is now loading in different steps. The menus will load after the content. So `content` seems more fitting then `initial`. Signed-off-by: Max --- src/components/EditorWrapper.vue | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/EditorWrapper.vue b/src/components/EditorWrapper.vue index b6941865eec..ada7d8f2873 100644 --- a/src/components/EditorWrapper.vue +++ b/src/components/EditorWrapper.vue @@ -58,7 +58,7 @@ :editor="tiptap" :content-wrapper="contentWrapper" :file-path="relativePath" /> - @@ -165,7 +165,7 @@ export default { idle: false, dirty: false, - initialLoading: false, + contentLoaded: false, lastSavedString: '', syncError: null, hasConnectionIssue: false, @@ -234,6 +234,12 @@ export default { displayed() { return this.currentSession && this.active }, + renderMenus() { + return this.contentLoaded + && this.isRichEditor + && !this.syncError + && !this.readOnly + }, }, watch: { lastSavedStatus() { @@ -406,7 +412,7 @@ export default { .on('error', (error, data) => { this.tiptap.setOptions({ editable: false }) if (error === ERROR_TYPE.SAVE_COLLISSION && (!this.syncError || this.syncError.type !== ERROR_TYPE.SAVE_COLLISSION)) { - this.initialLoading = true + this.contentLoaded = true this.syncError = { type: error, data, @@ -472,7 +478,7 @@ export default { }, reconnect() { - this.initialLoading = false + this.contentLoaded = false this.hasConnectionIssue = false if (this.syncService) { this.syncService.close().then(() => {