Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deleting rich workspaces readme.md #4782

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Changes from all commits
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
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)
luka-nextcloud marked this conversation as resolved.
Show resolved Hide resolved
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
Loading