summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Schatz <jacobschatz@Jacobs-MBP.fios-router.home>2016-01-18 15:40:48 -0500
committerJacob Schatz <jacobschatz@Jacobs-MBP.fios-router.home>2016-01-18 15:40:48 -0500
commitc298068c45682ad2b75727029872878cd3cc5522 (patch)
treeac787a1fc9171fc85e52df380cf24e7c2af80bf9
parent419bff801be88eb3e2fd1be2e3c6d02514a478bd (diff)
downloadgitlab-ce-c298068c45682ad2b75727029872878cd3cc5522.tar.gz
Fix underlying issue with emoji reactions
Issue was: blank space was rendering as a element in an array of authors. Element was being used by `join`. Original fix !2450 was trying to remove the space after it happened. This checks properly for it and only moves forward if it does not exist. Also removes "me" upon unchecking emoji.
-rw-r--r--app/assets/javascripts/awards_handler.coffee14
1 files changed, 8 insertions, 6 deletions
diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee
index 2c9c99d502f..42644229490 100644
--- a/app/assets/javascripts/awards_handler.coffee
+++ b/app/assets/javascripts/awards_handler.coffee
@@ -44,8 +44,7 @@ class @AwardsHandler
decrementCounter: (emoji) ->
counter = @findEmojiIcon(emoji).siblings(".counter")
emojiIcon = counter.parent()
-
- if parseInt(counter.text()) > 1
+ if parseInt(counter.text()) > 0
counter.text(parseInt(counter.text()) - 1)
emojiIcon.removeClass("active")
@removeMeFromAuthorList(emoji)
@@ -60,16 +59,19 @@ class @AwardsHandler
removeMeFromAuthorList: (emoji) ->
award_block = @findEmojiIcon(emoji).parent()
authors = award_block.attr("data-original-title").split(", ")
- authors = _.without(authors, "me").join(", ")
- award_block.attr("title", authors)
+ if authors.indexOf("me") != -1
+ authors.splice(authors.indexOf("me"),1)
+ award_block.closest(".award").attr("data-original-title", authors.join(", "))
@resetTooltip(award_block)
addMeToAuthorList: (emoji) ->
award_block = @findEmojiIcon(emoji).parent()
- authors = award_block.attr("data-original-title").trim().split(", ")
+ origTitle = award_block.attr("data-original-title").trim()
+ authors = []
+ if origTitle
+ authors = origTitle.split(', ')
if authors.indexOf("me") == -1
authors.push("me")
- console.log('authors');
award_block.attr("title", authors.join(", "))
@resetTooltip(award_block)