From 62571ae1f221477bd982160fb407bb08d7bc0a8e Mon Sep 17 00:00:00 2001 From: Jacob Schatz Date: Fri, 15 Jan 2016 16:24:16 -0500 Subject: [PATCH 1/5] Fixes tooltip doesn't duplicate the "me" name. Checks that "me" is not in the array of names in tooltip --- app/assets/javascripts/awards_handler.coffee | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee index 9d5ae6c04e9..5ab509b52c1 100644 --- a/app/assets/javascripts/awards_handler.coffee +++ b/app/assets/javascripts/awards_handler.coffee @@ -66,14 +66,10 @@ class @AwardsHandler addMeToAuthorList: (emoji) -> award_block = @findEmojiIcon(emoji).parent() - authors = _.compact(award_block.attr("data-original-title").split(", ")) - authors.push("me") - - if authors.length == 1 - award_block.attr("title", "me") - else - award_block.attr("title", authors.join(", ")) - + authors = award_block.attr("data-original-title").split(", ") + if authors.indexOf("me") == -1 + authors.push("me") + award_block.attr("title", authors.join(", ")) @resetTooltip(award_block) resetTooltip: (award) -> From 419bff801be88eb3e2fd1be2e3c6d02514a478bd Mon Sep 17 00:00:00 2001 From: Jacob Schatz Date: Mon, 18 Jan 2016 11:12:13 -0500 Subject: [PATCH 2/5] Removing initial `,`. --- app/assets/javascripts/awards_handler.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee index 5ab509b52c1..2c9c99d502f 100644 --- a/app/assets/javascripts/awards_handler.coffee +++ b/app/assets/javascripts/awards_handler.coffee @@ -66,9 +66,10 @@ class @AwardsHandler addMeToAuthorList: (emoji) -> award_block = @findEmojiIcon(emoji).parent() - authors = award_block.attr("data-original-title").split(", ") + authors = award_block.attr("data-original-title").trim().split(", ") if authors.indexOf("me") == -1 authors.push("me") + console.log('authors'); award_block.attr("title", authors.join(", ")) @resetTooltip(award_block) From c298068c45682ad2b75727029872878cd3cc5522 Mon Sep 17 00:00:00 2001 From: Jacob Schatz Date: Mon, 18 Jan 2016 15:40:48 -0500 Subject: [PATCH 3/5] 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. --- app/assets/javascripts/awards_handler.coffee | 14 ++++++++------ 1 file 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) From c426a571dbdffcedee4200f5acc56aae02df3bf9 Mon Sep 17 00:00:00 2001 From: Jacob Schatz Date: Mon, 18 Jan 2016 19:27:59 -0500 Subject: [PATCH 4/5] Fix the situation where the user has named themselves "me" Stopped looking for existing user since remove functionality is fixed. --- app/assets/javascripts/awards_handler.coffee | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee index 42644229490..7136ef3258b 100644 --- a/app/assets/javascripts/awards_handler.coffee +++ b/app/assets/javascripts/awards_handler.coffee @@ -59,8 +59,7 @@ class @AwardsHandler removeMeFromAuthorList: (emoji) -> award_block = @findEmojiIcon(emoji).parent() authors = award_block.attr("data-original-title").split(", ") - if authors.indexOf("me") != -1 - authors.splice(authors.indexOf("me"),1) + authors.splice(authors.indexOf("me"),1) award_block.closest(".award").attr("data-original-title", authors.join(", ")) @resetTooltip(award_block) @@ -70,8 +69,7 @@ class @AwardsHandler authors = [] if origTitle authors = origTitle.split(', ') - if authors.indexOf("me") == -1 - authors.push("me") + authors.push("me") award_block.attr("title", authors.join(", ")) @resetTooltip(award_block) From e5cbd5885a5cf72f406a6a4cb471b59a87865d20 Mon Sep 17 00:00:00 2001 From: Jacob Schatz Date: Tue, 19 Jan 2016 15:43:04 -0500 Subject: [PATCH 5/5] Fixes issue where other emoji (not thumbup/thumbdown) were not removed --- app/assets/javascripts/awards_handler.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee index 7136ef3258b..1ef31c7700e 100644 --- a/app/assets/javascripts/awards_handler.coffee +++ b/app/assets/javascripts/awards_handler.coffee @@ -44,7 +44,7 @@ class @AwardsHandler decrementCounter: (emoji) -> counter = @findEmojiIcon(emoji).siblings(".counter") emojiIcon = counter.parent() - if parseInt(counter.text()) > 0 + if parseInt(counter.text()) > 1 counter.text(parseInt(counter.text()) - 1) emojiIcon.removeClass("active") @removeMeFromAuthorList(emoji)