aboutsummaryrefslogtreecommitdiff
path: root/src/components/attachment/attachment.js
blob: 47ca03de0781927aa07150cc29e0b540003b9be0 (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
37
38
39
40
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'
      };

      if (this.attachment.mimetype.match(/ogg|audio/)) {
        type = 'audio'
      }

      return type
    }
  },
  methods: {
    showNsfw () {
      this.$store.commit('setNsfw', { id: this.statusId, nsfw: false })
    }
  }
}

export default Attachment