Skip to content

Commit

Permalink
fix: deleting rich workspaces readme.md
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Trovic <[email protected]>
  • Loading branch information
luka-nextcloud committed Sep 12, 2023
1 parent e6119e0 commit c689613
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/views/RichWorkspace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import RichTextReader from '../components/RichTextReader.vue'

const IS_PUBLIC = !!(document.getElementById('isPublic'))
const WORKSPACE_URL = generateOcsUrl('apps/text' + (IS_PUBLIC ? '/public' : '') + '/workspace', 2)
const SUPPORTED_STATIC_FILENAMES = ['Readme.md', 'README.md', 'readme.md']

export default {
name: 'RichWorkspace',
Expand Down Expand Up @@ -112,13 +113,17 @@ export default {
}
subscribe('Text::showRichWorkspace', this.showRichWorkspace)
subscribe('Text::hideRichWorkspace', this.hideRichWorkspace)
subscribe('files:node:deleted', this.onFileDeleted)
subscribe('files:node:renamed', this.onFileRenamed)

this.listenKeydownEvents()

},
beforeDestroy() {
unsubscribe('Text::showRichWorkspace', this.showRichWorkspace)
unsubscribe('Text::hideRichWorkspace', this.hideRichWorkspace)
unsubscribe('files:node:deleted', this.onFileDeleted)
unsubscribe('files:node:renamed', this.onFileRenamed)

this.unlistenKeydownEvents()
},
Expand Down Expand Up @@ -203,6 +208,18 @@ export default {
// schedule to normal behaviour
this.$_timeoutAutohide = setTimeout(this.onTimeoutAutohide, 7000) // 7s
},
onFileDeleted(node) {
if (node.path === this.file.path) {
this.hideRichWorkspace()
}
},
onFileRenamed(node) {
if (SUPPORTED_STATIC_FILENAMES.includes(node.basename)) {
this.showRichWorkspace()
} else if (node.fileid === this.file?.id && node.path !== this.file?.path) {
this.hideRichWorkspace()
}
},
},
}
</script>
Expand Down

0 comments on commit c689613

Please sign in to comment.