Skip to content

Commit

Permalink
fix: Use files:node:created event
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Nov 13, 2023
1 parent b5bafad commit f73bd2f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/Menu/ActionList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
<component :is="icon" :key="iconKey" />
</template>
<ActionSingle v-for="child in children"
:key="`child-${child.key}`"
:id="`${$menuID}-child-${child.key}`"
:key="`child-${child.key}`"
is-item
:action-entry="child"
v-on="$listeners"
Expand Down
7 changes: 3 additions & 4 deletions src/helpers/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,9 @@ export const addMenuRichWorkspace = () => {

showSuccess(t('text', 'Created "{name}"', { name: descriptionFile }))

emit('files:node:created', file)
setTimeout(() => {
emit('Text::showRichWorkspace', { autofocus: true })
}, 200)
// We need a timeout as an empty file list does not render the header RichWorkspace component
// so it is not catching the event that early
setTimeout(() => emit('files:node:created', file), 200)
},
})
}
Expand Down
7 changes: 7 additions & 0 deletions src/views/RichWorkspace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export default {
}
subscribe('Text::showRichWorkspace', this.showRichWorkspace)
subscribe('Text::hideRichWorkspace', this.hideRichWorkspace)
subscribe('files:node:created', this.onFileCreated)
subscribe('files:node:deleted', this.onFileDeleted)
subscribe('files:node:renamed', this.onFileRenamed)
Expand All @@ -121,6 +122,7 @@ export default {
beforeDestroy() {
unsubscribe('Text::showRichWorkspace', this.showRichWorkspace)
unsubscribe('Text::hideRichWorkspace', this.hideRichWorkspace)
unsubscribe('files:node:created', this.onFileCreated)
unsubscribe('files:node:deleted', this.onFileDeleted)
unsubscribe('files:node:renamed', this.onFileRenamed)
Expand Down Expand Up @@ -208,6 +210,11 @@ export default {
// schedule to normal behaviour
this.$_timeoutAutohide = setTimeout(this.onTimeoutAutohide, 7000) // 7s
},
onFileCreated(node) {
if (SUPPORTED_STATIC_FILENAMES.includes(node.basename)) {
this.showRichWorkspace()
}
},
onFileDeleted(node) {
if (node.path === this.file.path) {
this.hideRichWorkspace()
Expand Down

0 comments on commit f73bd2f

Please sign in to comment.