Skip to content

Commit

Permalink
Comment#score_for_user: show nothing when the user can't downvote
Browse files Browse the repository at this point in the history
the upvote with dash looked weird, so only show a mark when there's
something below it (downvote).  change dash to a tilde to look more
in flux.
  • Loading branch information
jcs committed Jul 27, 2017
1 parent 9e9c294 commit 30057c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/assets/javascripts/application.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ var _Lobsters = Class.extend({

var li = $(voterEl).closest(".story, .comment");
var scoreDiv = li.find("div.score").get(0);
var score = 0;
var showScore = true;
if (scoreDiv.innerHTML == "-")
var score = parseInt(scoreDiv.innerHTML);
if (isNaN(score)) {
showScore = false;
else
score = parseInt(scoreDiv.innerHTML);
score = 0;
}
var action = "";

if (li.hasClass("upvoted") && point > 0) {
Expand Down
4 changes: 3 additions & 1 deletion app/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,10 @@ def score
def score_for_user(u)
if self.showing_downvotes_for_user?(u)
score
elsif u && u.can_downvote?(self)
"~"
else
"-"
" ".html_safe
end
end

Expand Down

0 comments on commit 30057c7

Please sign in to comment.