Fix Regression: Heart filled icon was shown on all voted comments

Heart filled icon should be an indication that the current user has
voted. Thanks to Pablo Vazques for pointing it out
This commit is contained in:
Tobias Johansson 2019-02-04 10:16:50 +01:00
parent f35c2529a6
commit 1101b8e716

View File

@ -3,7 +3,7 @@ import { UnitOfWorkTracker } from '../mixins/UnitOfWorkTracker'
import { thenVoteComment } from '../../api/comments'
const TEMPLATE = `
<div class="comment-rating"
:class="{rated: hasRating, positive: isPositive }"
:class="{rated: currentUserHasRated, positive: currentUserRatedPositive }"
>
<div class="comment-rating-value" title="Number of likes">{{ rating }}</div>
<div class="comment-action-rating up" title="Like comment"
@ -27,11 +27,11 @@ Vue.component('comment-rating', {
rating() {
return this.positiveRating - this.negativeRating;
},
isPositive() {
return this.rating > 0;
currentUserRatedPositive() {
return this.comment.current_user_rating === true;
},
hasRating() {
return (this.positiveRating || this.negativeRating) !== 0;
currentUserHasRated() {
return typeof this.comment.current_user_rating === "boolean" ;
},
canVote() {
return this.comment.user.id !== pillar.utils.getCurrentUser().user_id;