Skip to content

Commit

Permalink
reactor(ImageView): Simplify attachmentType/isMediaAttachment logic
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- authored and backportbot-nextcloud[bot] committed Nov 29, 2023
1 parent b3be90a commit e391298
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/nodes/ImageView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ export default {
showIcons: false,
imageUrl: null,
errorMessage: null,
attachmentType: null,
attachmentSize: null,
showImageModal: false,
imageIndex: null,
Expand All @@ -187,8 +186,15 @@ export default {
...mapGetters({
imageAttachments: 'text/imageAttachments',
}),
attachmentType() {
if (this.attachment) {
return this.attachment.isImage ? 'image' : 'media'
} else {
return null
}
},
isMediaAttachment() {
return this.attachmentType === this.$attachmentResolver.ATTACHMENT_TYPE_MEDIA
return this.attachmentType === 'media'
},
showDeleteIcon() {
return this.isEditable && this.showIcons
Expand Down Expand Up @@ -241,7 +247,6 @@ export default {
this.imageUrl = this.attachment.previewUrl
this.imageLoaded = true
this.loaded = true
this.attachmentType = this.attachment.isImage ? this.$attachmentResolver.ATTACHMENT_TYPE_IMAGE : this.$attachmentResolver.ATTACHMENT_TYPE_MEDIA
this.attachmentSize = this.attachment.size
}
img.onerror = (e) => {
Expand Down
3 changes: 0 additions & 3 deletions src/services/AttachmentResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ export default class AttachmentResolver {
#documentId
#initAttachmentListPromise

ATTACHMENT_TYPE_IMAGE = 'image'
ATTACHMENT_TYPE_MEDIA = 'media'

constructor({ session, user, shareToken, currentDirectory, fileId }) {
this.#session = session
this.#user = user
Expand Down

0 comments on commit e391298

Please sign in to comment.