From 38444f3165db376d3ca4e5a70c77ce7beac1bb5e Mon Sep 17 00:00:00 2001 From: Yonle Date: Fri, 27 Feb 2026 04:12:47 +0700 Subject: [PATCH 1/4] attachment: fix over reliance on fileType() Signed-off-by: Yonle --- src/components/attachment/attachment.js | 26 +++++++------------ src/components/attachment/attachment.vue | 24 ++++++++--------- .../chat_list_item/chat_list_item.js | 4 +-- src/components/gallery/gallery.js | 12 +++------ src/components/media_modal/media_modal.js | 11 ++------ src/components/media_modal/media_modal.vue | 8 +++--- .../post_status_form/post_status_form.js | 4 --- src/components/status_body/status_body.js | 4 +-- .../entity_normalizer.service.js | 6 +++++ src/stores/media_viewer.js | 5 +--- 10 files changed, 41 insertions(+), 63 deletions(-) diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index db5171c80..f7c5340e3 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -1,7 +1,6 @@ import { mapGetters } from 'vuex' import nsfwImage from '../../assets/nsfw.png' -import fileTypeService from '../../services/file_type/file_type.service.js' import Flash from '../flash/flash.vue' import StillImage from '../still-image/still-image.vue' import VideoAttachment from '../video_attachment/video_attachment.vue' @@ -61,9 +60,7 @@ const Attachment = { hideNsfwLocal: this.$store.getters.mergedConfig.hideNsfw, preloadImage: this.$store.getters.mergedConfig.preloadImage, loading: false, - img: - fileTypeService.fileType(this.attachment.mimetype) === 'image' && - document.createElement('img'), + img: this.attachment.type == "image" && document.createElement('img'), modalOpen: false, showHidden: false, flashLoaded: false, @@ -84,7 +81,7 @@ const Attachment = { '-editable': this.edit !== undefined, '-compact': this.compact, }, - '-type-' + this.type, + '-type-' + this.attachment.type, this.size && '-size-' + this.size, `-${this.useContainFit ? 'contain' : 'cover'}-fit`, ] @@ -97,14 +94,14 @@ const Attachment = { }, placeholderName() { if (this.attachment.description === '' || !this.attachment.description) { - return this.type.toUpperCase() + return this.attachment.type.toUpperCase() } return this.attachment.description }, placeholderIconClass() { - if (this.type === 'image') return 'image' - if (this.type === 'video') return 'video' - if (this.type === 'audio') return 'music' + if (this.attachment.type === 'image') return 'image' + if (this.attachment.type === 'video') return 'video' + if (this.attachment.type === 'audio') return 'music' return 'file' }, referrerpolicy() { @@ -112,14 +109,11 @@ const Attachment = { ? '' : 'no-referrer' }, - type() { - return fileTypeService.fileType(this.attachment.mimetype) - }, hidden() { return this.nsfw && this.hideNsfwLocal && !this.showHidden }, isEmpty() { - return this.type === 'html' && !this.attachment.oembed + return this.attachment.type === 'html' && !this.attachment.oembed }, useModal() { let modalTypes = [] @@ -134,7 +128,7 @@ const Attachment = { : ['image'] break } - return modalTypes.includes(this.type) + return modalTypes.includes(this.attachment.type) }, videoTag() { return this.useModal ? 'button' : 'span' @@ -159,7 +153,7 @@ const Attachment = { if (this.useModal) { this.$emit('setMedia') useMediaViewerStore().setCurrentMedia(this.attachment) - } else if (this.type === 'unknown') { + } else if (this.attachment.type === 'unknown') { window.open(this.attachment.url) } }, @@ -192,7 +186,7 @@ const Attachment = { if ( this.mergedConfig.useOneClickNsfw && !this.showHidden && - (this.type !== 'video' || this.mergedConfig.playVideosInModal) + (this.attachment.type !== 'video' || this.mergedConfig.playVideosInModal) ) { this.openModal(event) return diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue index 696d3bb8a..0db86ff8a 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -6,7 +6,7 @@ @click="openModal" > @@ -80,7 +80,7 @@ class="attachment-buttons" >