comments: allow votes to be soft deleted.
Make it so that when a user removes their own vote, the vote is soft deleted (the is_deleted flag is set) instead of hard deleted. Changes: * Add is_deleted flag to comment votes. * Relax uniqueness constraint so you can have multiple deleted votes on the same comment. You can still only have one active vote on the comment. * Add `soft_delete` method to Deletable concern.
This commit is contained in:
@@ -28,12 +28,12 @@ class CommentComponent < ApplicationComponent
|
||||
|
||||
def upvoted?
|
||||
return false if current_user.is_anonymous?
|
||||
comment.votes.select(&:is_positive?).map(&:user_id).include?(current_user.id)
|
||||
comment.votes.active.select(&:is_positive?).map(&:user_id).include?(current_user.id)
|
||||
end
|
||||
|
||||
def downvoted?
|
||||
return false if current_user.is_anonymous?
|
||||
comment.votes.select(&:is_negative?).map(&:user_id).include?(current_user.id)
|
||||
comment.votes.active.select(&:is_negative?).map(&:user_id).include?(current_user.id)
|
||||
end
|
||||
|
||||
def reported?
|
||||
|
||||
Reference in New Issue
Block a user