aboutsummaryrefslogtreecommitdiff
path: root/src/components/attachment/attachment.js
blob: 85d924d02f4e2e3609806c95cb4f0896e6952ac0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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