Skip to content

Commit

Permalink
refactor: extract logic into computed
Browse files Browse the repository at this point in the history
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 <max@nextcloud.com>
  • Loading branch information
max-nextcloud authored and backportbot[bot] committed Mar 9, 2022
1 parent 939963b commit 3b41435
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/components/EditorWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
:editor="tiptap"
:content-wrapper="contentWrapper"
:file-path="relativePath" />
<EditorContent v-show="initialLoading"
<EditorContent v-show="contentLoaded"
class="editor__content"
:editor="tiptap" />
</div>
Expand Down Expand Up @@ -165,7 +165,7 @@ export default {
idle: false,
dirty: false,
initialLoading: false,
contentLoaded: false,
lastSavedString: '',
syncError: null,
hasConnectionIssue: false,
Expand Down Expand Up @@ -234,6 +234,12 @@ export default {
displayed() {
return this.currentSession && this.active
},
renderMenus() {
return this.contentLoaded
&& this.isRichEditor
&& !this.syncError
&& !this.readOnly
},
},
watch: {
lastSavedStatus() {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -472,7 +478,7 @@ export default {
},
reconnect() {
this.initialLoading = false
this.contentLoaded = false
this.hasConnectionIssue = false
if (this.syncService) {
this.syncService.close().then(() => {
Expand Down

0 comments on commit 3b41435

Please sign in to comment.