From ddca5774a5eda2b0fabfc4d1e4071fac5a6a621d Mon Sep 17 00:00:00 2001 From: Luka Trovic Date: Thu, 7 Sep 2023 18:42:25 +0200 Subject: [PATCH] fix: deleting rich workspaces readme.md Signed-off-by: Luka Trovic --- src/views/RichWorkspace.vue | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/views/RichWorkspace.vue b/src/views/RichWorkspace.vue index 44c9acb1e29..6fee98ff201 100644 --- a/src/views/RichWorkspace.vue +++ b/src/views/RichWorkspace.vue @@ -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', @@ -112,6 +113,8 @@ 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() @@ -119,6 +122,8 @@ export default { 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() }, @@ -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() + } + }, }, }