diff options
| author | lain <lain@soykaf.club> | 2020-01-28 15:24:56 +0000 |
|---|---|---|
| committer | lain <lain@soykaf.club> | 2020-01-28 15:24:56 +0000 |
| commit | 73253b87bfce0466848231da47e1864c6ff639b0 (patch) | |
| tree | 732aff3bd3007c26c67e3de00a27379751b3a8a3 /src/components/emoji_reactions/emoji_reactions.js | |
| parent | 4a11ee9768f2abbaa9da0e2454e2793734cce040 (diff) | |
| parent | 6afff4f8c205ec70d3694564c706f6a46a61db9e (diff) | |
Merge branch 'feat/emoji-reactions' into 'develop'
Emoji reactions
See merge request pleroma/pleroma-fe!1049
Diffstat (limited to 'src/components/emoji_reactions/emoji_reactions.js')
| -rw-r--r-- | src/components/emoji_reactions/emoji_reactions.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/components/emoji_reactions/emoji_reactions.js b/src/components/emoji_reactions/emoji_reactions.js new file mode 100644 index 00000000..95d52cb6 --- /dev/null +++ b/src/components/emoji_reactions/emoji_reactions.js @@ -0,0 +1,32 @@ + +const EmojiReactions = { + name: 'EmojiReactions', + props: ['status'], + computed: { + emojiReactions () { + return this.status.emoji_reactions + } + }, + methods: { + reactedWith (emoji) { + 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) + }, + 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 |
