votes: fix bug with removing votes multiple times.
Fix an issue where if you tried to remove the same vote multiple times, nothing would happen. Specifically, if you upvoted a post in one tab, then opened it in a second tab, then removed your vote in the first tab, then upvoted it again in the first tab, then tried to remove your vote again in the second tab, nothing would happen when removing it in the second tab. This was because we were removing votes by vote ID, which meant that if a vote had already been removed, removing it again would do nothing since it was already deleted.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<% if current_user.is_anonymous? %>
|
||||
<%= link_to upvote_icon, login_path(url: request.fullpath), class: "post-upvote-link inactive-link" %>
|
||||
<% elsif upvoted? %>
|
||||
<%= link_to upvote_icon, post_vote_path(current_vote), class: "post-upvote-link post-unvote-link active-link", method: :delete, remote: true %>
|
||||
<%= link_to upvote_icon, post_post_votes_path(post), class: "post-upvote-link post-unvote-link active-link", method: :delete, remote: true %>
|
||||
<% else %>
|
||||
<%= link_to upvote_icon, post_post_votes_path(post_id: post.id, score: 1), class: "post-upvote-link inactive-link", method: :post, remote: true %>
|
||||
<% end %>
|
||||
@@ -14,7 +14,7 @@
|
||||
<% if current_user.is_anonymous? %>
|
||||
<%= link_to downvote_icon, login_path(url: request.fullpath), class: "post-downvote-link inactive-link" %>
|
||||
<% elsif downvoted? %>
|
||||
<%= link_to downvote_icon, post_vote_path(current_vote), class: "post-downvote-link post-unvote-link active-link", method: :delete, remote: true %>
|
||||
<%= link_to downvote_icon, post_post_votes_path(post), class: "post-downvote-link post-unvote-link active-link", method: :delete, remote: true %>
|
||||
<% else %>
|
||||
<%= link_to downvote_icon, post_post_votes_path(post_id: post.id, score: -1), class: "post-downvote-link inactive-link", method: :post, remote: true %>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user