Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Keep track of local state of the rich workspace separately
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Nov 22, 2023
commit add903441167689ceb9b9cd97a5fedb28c6441ee
19 changes: 14 additions & 5 deletions src/views/RichWorkspace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
-->

<template>
<div v-if="enabled && file !== null"
<div v-if="enabled && localHasRichWorkspace"
id="rich-workspace"
:class="{'focus': focus, 'dark': darkTheme }">
<RichTextReader v-if="!loaded || !ready" :content="content" class="rich-workspace--preview" />
Expand Down Expand Up @@ -80,6 +80,8 @@ export default {
},
data() {
return {
// Keep track of a local copy of the hasRichWorkspace state as it might change after intitial rendering (e.g. when adding/removing the readme)
localHasRichWorkspace: false,
focus: false,
folder: null,
file: null,
Expand All @@ -105,8 +107,12 @@ export default {
document.querySelector('#rich-workspace .text-editor__main').scrollTo(0, 0)
}
},
hasRichWorkspace(value) {
this.localHasRichWorkspace = value
},
},
mounted() {
this.localHasRichWorkspace = this.hasRichWorkspace
if (this.enabled && this.hasRichWorkspace) {
this.getFileInfo()
}
Expand Down Expand Up @@ -137,6 +143,7 @@ export default {
this.unlistenKeydownEvents()
},
reset() {
this.localHasRichWorkspace = false
this.file = null
this.focus = false
this.$nextTick(() => {
Expand Down Expand Up @@ -164,6 +171,7 @@ export default {
this.editing = true
this.loaded = true
this.autofocus = autofocus || false
this.localHasRichWorkspace = true
return true
})
.catch((error) => {
Expand Down Expand Up @@ -212,19 +220,20 @@ export default {
},
onFileCreated(node) {
if (SUPPORTED_STATIC_FILENAMES.includes(node.basename)) {
this.showRichWorkspace()
this.localHasRichWorkspace = true
this.getFileInfo(true)
}
},
onFileDeleted(node) {
if (node.path === this.file.path) {
this.hideRichWorkspace()
this.localHasRichWorkspace = false
}
},
onFileRenamed(node) {
if (SUPPORTED_STATIC_FILENAMES.includes(node.basename)) {
this.showRichWorkspace()
this.localHasRichWorkspace = true
} else if (node.fileid === this.file?.id && node.path !== this.file?.path) {
this.hideRichWorkspace()
this.localHasRichWorkspace = false
}
},
},
Expand Down