diff options
author | Phil Hughes <me@iamphill.com> | 2016-04-22 17:01:53 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-04-22 17:01:53 +0100 |
commit | 319c9360551280f7345c5d16ffb34fe5e73a1598 (patch) | |
tree | 90668f844ad4310aa738146e0996262cd14fb073 | |
parent | d5398e9656c1174d4d5be5a8cdad2a26d7587a27 (diff) | |
download | gitlab-ce-319c9360551280f7345c5d16ffb34fe5e73a1598.tar.gz |
Fixes issue with emoji comments not showing correct emoji image
Previously it would look for the unicode character inside the award menu. But this menu might not always be there.
Now, the unicode characters are loaded onto the page in an array which the award emoji that looks in to get the correct emoji unicode character
Fixes #15512
-rw-r--r-- | app/assets/javascripts/awards_handler.coffee | 14 | ||||
-rw-r--r-- | app/views/votes/_votes_block.html.haml | 4 | ||||
-rw-r--r-- | lib/award_emoji.rb | 5 |
3 files changed, 10 insertions, 13 deletions
diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee index af4462ece38..a17867f8c9b 100644 --- a/app/assets/javascripts/awards_handler.coffee +++ b/app/assets/javascripts/awards_handler.coffee @@ -1,5 +1,5 @@ class @AwardsHandler - constructor: (@get_emojis_url, @post_emoji_url, @noteable_type, @noteable_id, @aliases) -> + constructor: (@get_emojis_url, @post_emoji_url, @noteable_type, @noteable_id, @unicodes) -> $(".js-add-award").on "click", (event) => event.stopPropagation() event.preventDefault() @@ -146,15 +146,7 @@ class @AwardsHandler $('.award-control').tooltip() resolveNameToCssClass: (emoji) -> - emoji_icon = $(".emoji-menu-content [data-emoji='#{emoji}']") - - if emoji_icon.length > 0 - unicodeName = emoji_icon.data("unicode-name") - else - # Find by alias - unicodeName = $(".emoji-menu-content [data-aliases*=':#{emoji}:']").data("unicode-name") - - "emoji-#{unicodeName}" + "emoji-#{@unicodes[emoji]}" postEmoji: (emoji, callback) -> $.post @post_emoji_url, { note: { @@ -174,7 +166,7 @@ class @AwardsHandler }, 200) normilizeEmojiName: (emoji) -> - @aliases[emoji] || emoji + emoji addEmojiToFrequentlyUsedList: (emoji) -> frequently_used_emojis = @getFrequentlyUsedEmojis() diff --git a/app/views/votes/_votes_block.html.haml b/app/views/votes/_votes_block.html.haml index dc249155b92..59e12798691 100644 --- a/app/views/votes/_votes_block.html.haml +++ b/app/views/votes/_votes_block.html.haml @@ -19,12 +19,12 @@ var post_emoji_url = "#{award_toggle_namespace_project_notes_path(@project.namespace, @project)}"; var noteable_type = "#{votable.class.name.underscore}"; var noteable_id = "#{votable.id}"; - var aliases = #{AwardEmoji.aliases.to_json}; + var unicodes = #{AwardEmoji.unicode.to_json}; window.awards_handler = new AwardsHandler( get_emojis_url, post_emoji_url, noteable_type, noteable_id, - aliases + unicodes ); diff --git a/lib/award_emoji.rb b/lib/award_emoji.rb index 5f8ff01b0a9..ad78bb530f4 100644 --- a/lib/award_emoji.rb +++ b/lib/award_emoji.rb @@ -52,6 +52,11 @@ class AwardEmoji end end + def self.unicode + emojis + emojis.map{|key, value| { key => emojis[key]["unicode"] } }.inject(:merge!) + end + def self.aliases @aliases ||= begin json_path = File.join(Rails.root, 'fixtures', 'emojis', 'aliases.json' ) |