aboutsummaryrefslogtreecommitdiff
path: root/src/components/react_button/react_button.js
blob: 6fb2a780276eb3443f728f77fb18e93859d6af9b (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
41
42
43
import { mapGetters } from 'vuex'

const ReactButton = {
  props: ['status', 'loggedIn'],
  data () {
    return {
      showTooltip: false,
      filterWord: '',
      popperOptions: {
        modifiers: {
          preventOverflow: { padding: { top: 50 }, boundariesElement: 'viewport' }
        }
      }
    }
  },
  methods: {
    openReactionSelect () {
      this.showTooltip = true
      this.filterWord = ''
    },
    closeReactionSelect () {
      this.showTooltip = false
    },
    addReaction (event, emoji) {
      this.$store.dispatch('reactWithEmoji', { id: this.status.id, emoji })
      this.closeReactionSelect()
    }
  },
  computed: {
    commonEmojis () {
      return ['❤️', '😠', '👀', '😂', '🔥']
    },
    emojis () {
      if (this.filterWord !== '') {
        return this.$store.state.instance.emoji.filter(emoji => emoji.displayText.includes(this.filterWord))
      }
      return this.$store.state.instance.emoji || []
    },
    ...mapGetters(['mergedConfig'])
  }
}

export default ReactButton