aboutsummaryrefslogtreecommitdiff
path: root/src/components/emoji_reactions/emoji_reactions.js
blob: e81e6e25380360d2423129661ed952d2c0b4cb6a (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

const EmojiReactions = {
  name: 'EmojiReactions',
  props: ['status'],
  computed: {
    emojiReactions () {
      return this.status.emojiReactions
    }
  },
  methods: {
    reactedWith (emoji) {
      return this.status.reactedWithEmoji.includes(emoji)
    },
    reactWith (emoji) {
      this.$store.dispatch('reactWithEmoji', { id: this.status.id, emoji })
    },
    unreact (emoji) {
      this.$store.dispatch('unreactWithEmoji', { id: this.status.id, emoji })
    },
    emojiOnClick (emoji, event) {
      if (this.reactedWith(emoji)) {
        this.unreact(emoji)
      } else {
        this.reactWith(emoji)
      }
    }
  }
}

export default EmojiReactions