akkoma-fe/src/components/attachment/attachment.js
2016-11-06 17:43:31 +01:00

36 lines
659 B
JavaScript

import nsfwImage from '../../assets/nsfw.jpg'
const Attachment = {
props: [
'attachment',
'nsfw',
'statusId'
],
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';
};
return type
}
},
methods: {
showNsfw () {
this.$store.commit('setNsfw', { id: this.statusId, nsfw: false })
}
}
}
export default Attachment