Skip to content

Commit

Permalink
Merge pull request #4782 from nextcloud/bugfix/deleting-readme
Browse files Browse the repository at this point in the history
fix: deleting rich workspaces readme.md
  • Loading branch information
juliushaertl committed Oct 27, 2023
2 parents d66f0a6 + ddca577 commit 2213539
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 2213539

Please sign in to comment.