2020-01-14 00:06:14 -08:00
|
|
|
|
|
|
|
const EmojiReactions = {
|
|
|
|
name: 'EmojiReactions',
|
|
|
|
props: ['status'],
|
|
|
|
computed: {
|
|
|
|
emojiReactions () {
|
2020-01-26 05:45:12 -08:00
|
|
|
return this.status.emoji_reactions
|
2020-01-14 00:06:14 -08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
reactedWith (emoji) {
|
2020-01-26 05:45:12 -08:00
|
|
|
const user = this.$store.state.users.currentUser
|
|
|
|
const reaction = this.status.emoji_reactions.find(r => r.emoji === emoji)
|
|
|
|
return reaction.accounts && reaction.accounts.find(u => u.id === user.id)
|
2020-01-14 00:06:14 -08:00
|
|
|
},
|
|
|
|
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
|