Make reactions removable

Co-authored-by: syuilo <syuilotan@yahoo.co.jp>

Resolve #367, resolve #2260, close #3503
This commit is contained in:
Aya Morisawa
2018-12-26 23:05:47 +09:00
parent dfc6ef4be6
commit 9b746f3eb5
3 changed files with 63 additions and 15 deletions

View File

@ -95,6 +95,7 @@ export default prop => ({
Vue.set(this.$_ns_target.reactionCounts, reaction, 0);
}
// Increment the count
this.$_ns_target.reactionCounts[reaction]++;
if (body.userId == this.$store.state.i.id) {
@ -103,6 +104,26 @@ export default prop => ({
break;
}
case 'unreacted': {
const reaction = body.reaction;
if (this.$_ns_target.reactionCounts == null) {
return;
}
if (this.$_ns_target.reactionCounts[reaction] == null) {
return;
}
// Decrement the count
if (this.$_ns_target.reactionCounts[reaction] > 0) this.$_ns_target.reactionCounts[reaction]--;
if (body.userId == this.$store.state.i.id) {
Vue.set(this.$_ns_target, 'myReaction', null);
}
break;
}
case 'pollVoted': {
if (body.userId == this.$store.state.i.id) return;
const choice = body.choice;