From 24471fc2d0cffe82d89e3bd0253986c2c4e473a6 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sun, 24 Jun 2018 16:35:38 +0000 Subject: [PATCH] Fix emote popup for certain emotes (i.e. <3) Fix #513 --- src/providers/twitch/twitchemotes.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/providers/twitch/twitchemotes.cpp b/src/providers/twitch/twitchemotes.cpp index b43ab3484..4dc8cca33 100644 --- a/src/providers/twitch/twitchemotes.cpp +++ b/src/providers/twitch/twitchemotes.cpp @@ -25,6 +25,7 @@ QString getEmoteLink(const QString &id, const QString &emoteScale) QString cleanUpCode(const QString &dirtyEmoteCode) { + QString cleanCode = dirtyEmoteCode; // clang-format off static QMap emoteNameReplacements{ {"[oO](_|\\.)[oO]", "O_o"}, {"\\>\\;\\(", ">("}, {"\\<\\;3", "<3"}, @@ -37,10 +38,13 @@ QString cleanUpCode(const QString &dirtyEmoteCode) auto it = emoteNameReplacements.find(dirtyEmoteCode); if (it != emoteNameReplacements.end()) { - return it.value(); + cleanCode = it.value(); } - return dirtyEmoteCode; + cleanCode.replace("<", "<"); + cleanCode.replace(">", ">"); + + return cleanCode; } void loadSetData(std::shared_ptr emoteSet) @@ -121,8 +125,6 @@ util::EmoteData TwitchEmotes::getEmoteById(const QString &id, const QString &emo return _twitchEmoteFromCache.getOrAdd(id, [&emoteName, &_emoteName, &id] { util::EmoteData newEmoteData; auto cleanCode = cleanUpCode(emoteName); - cleanCode.replace("<", "<"); - cleanCode.replace(">", ">"); newEmoteData.image1x = new messages::Image(getEmoteLink(id, "1.0"), 1, emoteName, _emoteName + "
Twitch Emote 1x"); newEmoteData.image1x->setCopyString(cleanCode);