From 65a0cfbcd30eb7bde4e24cdb1680b3e03d8b1992 Mon Sep 17 00:00:00 2001 From: Eric Mastro Date: Mon, 10 May 2021 14:33:28 +1000 Subject: [PATCH] fix: show emoji in reaction tooltip MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: #2387. Shows the emoji in the emoji reaction tooltip instead of the shorthand (ie 👎 instead of `:thumbsdown:`). --- .../MessageComponents/EmojiReactions.qml | 13 ++++-------- ui/imports/Emoji.qml | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/EmojiReactions.qml b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/EmojiReactions.qml index 9f961bdccf..0db1e72b03 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/EmojiReactions.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/EmojiReactions.qml @@ -46,16 +46,11 @@ Item { //% " reacted with " tooltip += qsTrId("-reacted-with-"); - - switch (emojiId) { - case 1: return tooltip + ":heart:" - case 2: return tooltip + ":thumbsup:" - case 3: return tooltip + ":thumbsdown:" - case 4: return tooltip + ":laughing:" - case 5: return tooltip + ":cry:" - case 6: return tooltip + ":angry:" - default: return tooltip + let emojiHtml = Emoji.getEmojiFromId(emojiId); + if (emojiHtml) { + tooltip += emojiHtml; } + return tooltip } Row { diff --git a/ui/imports/Emoji.qml b/ui/imports/Emoji.qml index 7c0291b4b5..d8922477b6 100644 --- a/ui/imports/Emoji.qml +++ b/ui/imports/Emoji.qml @@ -71,4 +71,25 @@ QtObject { }) return String.fromCodePoint(...codePointParts); } + + function getShortcodeFromId(emojiId) { + switch (emojiId) { + case 1: return ":heart:" + case 2: return ":thumbsup:" + case 3: return ":thumbsdown:" + case 4: return ":laughing:" + case 5: return ":cry:" + case 6: return ":angry:" + default: return undefined + } + } + + function getEmojiFromId(emojiId) { + let shortcode = Emoji.getShortcodeFromId(emojiId) + let emojiUnicode = Emoji.getEmojiUnicode(shortcode) + if (emojiUnicode) { + return Emoji.fromCodePoint(emojiUnicode) + } + return undefined + } }