clean up code, fix prediction bug

This commit is contained in:
Shpuld Shpuldson 2020-01-14 10:06:14 +02:00
parent b32888194c
commit b10b92a876
7 changed files with 122 additions and 89 deletions

View file

@ -0,0 +1,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