diff options
Diffstat (limited to 'src/components/attachment')
| -rw-r--r-- | src/components/attachment/attachment.js | 23 | ||||
| -rw-r--r-- | src/components/attachment/attachment.vue | 5 |
2 files changed, 7 insertions, 21 deletions
diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index 47ca03de..9f751863 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -1,4 +1,5 @@ import nsfwImage from '../../assets/nsfw.jpg' +import fileTypeService from '../../services/file_type/file_type.service.js' const Attachment = { props: [ @@ -9,25 +10,7 @@ const Attachment = { data: () => ({ nsfwImage }), computed: { type () { - let type = 'unknown' - - if (this.attachment.mimetype.match(/text\/html/)) { - type = 'html' - } - - if (this.attachment.mimetype.match(/image/)) { - type = 'image' - } - - if (this.attachment.mimetype.match(/video\/(webm|mp4)/)) { - type = 'video' - }; - - if (this.attachment.mimetype.match(/ogg|audio/)) { - type = 'audio' - } - - return type + return fileTypeService.fileType(this.attachment.mimetype) } }, methods: { @@ -37,4 +20,4 @@ const Attachment = { } } -export default Attachment +export default Attachment
\ No newline at end of file diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue index d5578c04..1e49cbeb 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -4,7 +4,10 @@ <img :key="nsfwImage" :src="nsfwImage"></img> </a> - <a class="image-attachment" v-if="type === 'image' && !nsfw" :href="attachment.url" target="_blank"><img :src="attachment.url"></img></a> + <a class="image-attachment" v-if="type === 'image' && !nsfw" + :href="attachment.url" target="_blank"> + <img :src="attachment.url"></img> + </a> <video v-if="type === 'video' && !nsfw" :src="attachment.url" controls></video> |
