From 02384f468f76b407fc9fd6fec090bcbc5b2bde63 Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Tue, 19 Sep 2023 19:52:13 +0200 Subject: [PATCH 1/3] add generateViewerObject util Signed-off-by: Maksim Sukharev --- .../Message/MessagePart/FilePreview.vue | 48 ++++------------- src/components/NewMessage/NewMessage.vue | 3 -- .../NewMessage/NewMessageNewFileDialog.vue | 2 +- src/composables/useViewer.js | 53 ++++++++++++++++++- 4 files changed, 61 insertions(+), 45 deletions(-) diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue index 135b131796..b166c49ce3 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue @@ -238,8 +238,12 @@ export default { emits: ['remove-file'], setup() { - const { openViewer } = useViewer() - return { openViewer } + const { openViewer, generateViewerObject } = useViewer() + + return { + openViewer, + generateViewerObject, + } }, data() { @@ -411,11 +415,7 @@ export default { }, internalAbsolutePath() { - if (this.path.startsWith('/')) { - return this.path - } - - return '/' + this.path + return this.path.startsWith('/') ? this.path : '/' + this.path }, isTemporaryUpload() { @@ -472,44 +472,14 @@ export default { event.stopPropagation() event.preventDefault() - let permissions = '' - if (this.permissions) { - if (this.permissions & OC.PERMISSION_CREATE) { - permissions += 'CK' - } - if (this.permissions & OC.PERMISSION_READ) { - permissions += 'G' - } - if (this.permissions & OC.PERMISSION_UPDATE) { - permissions += 'W' - } - if (this.permissions & OC.PERMISSION_DELETE) { - permissions += 'D' - } - if (this.permissions & OC.PERMISSION_SHARE) { - permissions += 'R' - } - } - - this.openViewer(this.internalAbsolutePath, [ - { - fileid: parseInt(this.id, 10), - filename: this.internalAbsolutePath, - basename: this.name, - mime: this.mimetype, - hasPreview: this.previewAvailable === 'yes', - etag: this.etag, - permissions, - }, - ]) + const fileInfo = this.generateViewerObject(this) + this.openViewer(this.internalAbsolutePath, [fileInfo], fileInfo) }, }, }