akkoma-fe/src/components/react_button/react_button.js

48 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-02-28 16:39:47 +00:00
import Popover from '../popover/popover.vue'
import { mapGetters } from 'vuex'
const ReactButton = {
2020-05-07 21:10:49 +00:00
props: ['status'],
data () {
return {
2020-02-28 16:39:47 +00:00
filterWord: ''
}
},
2020-02-28 16:39:47 +00:00
components: {
Popover
},
methods: {
2020-02-28 16:39:47 +00:00
addReaction (event, emoji, close) {
const existingReaction = this.status.emoji_reactions.find(r => r.name === emoji)
if (existingReaction && existingReaction.me) {
this.$store.dispatch('unreactWithEmoji', { id: this.status.id, emoji })
} else {
this.$store.dispatch('reactWithEmoji', { id: this.status.id, emoji })
}
2020-02-28 16:39:47 +00:00
close()
}
},
computed: {
commonEmojis () {
return ['👍', '😠', '👀', '😂', '🔥']
},
emojis () {
if (this.filterWord !== '') {
2020-07-14 19:47:02 +00:00
const filterWordLowercase = this.filterWord.toLowerCase()
const orderedEmojiList = []
for (const emoji of this.$store.state.instance.emoji) {
2020-09-21 15:42:17 +00:00
const indexOfFilterWord = emoji.displayText.toLowerCase().indexOf(filterWordLowercase)
if (indexOfFilterWord > -1) {
orderedEmojiList.splice(indexOfFilterWord, 0, emoji)
}
}
return orderedEmojiList
}
return this.$store.state.instance.emoji || []
},
...mapGetters(['mergedConfig'])
}
}
export default ReactButton