diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ad7b19a2..79aa0f270 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unversioned +- Bugfix: Fixed "smiley" emotes being unable to be "Tabbed" with autocompletion, introduced in v2.3.3. (#3010) + ## 2.3.3 - Major: Added username autocompletion popup menu when typing usernames with an @ prefix. (#1979, #2866) diff --git a/src/messages/layouts/MessageLayoutElement.cpp b/src/messages/layouts/MessageLayoutElement.cpp index 62b9e16db..ad5d20879 100644 --- a/src/messages/layouts/MessageLayoutElement.cpp +++ b/src/messages/layouts/MessageLayoutElement.cpp @@ -111,7 +111,7 @@ void ImageLayoutElement::addCopyTextToString(QString &str, int from, if (emoteElement) { str += emoteElement->getEmote()->getCopyString(); - str = TwitchEmotes::cleanUpEmoteCode(EmoteName{str}); + str = TwitchEmotes::cleanUpEmoteCode(str); if (this->hasTrailingSpace()) { str += " "; diff --git a/src/providers/twitch/TwitchAccount.cpp b/src/providers/twitch/TwitchAccount.cpp index d4862d223..dc0909893 100644 --- a/src/providers/twitch/TwitchAccount.cpp +++ b/src/providers/twitch/TwitchAccount.cpp @@ -240,12 +240,10 @@ void TwitchAccount::loadEmotes() KrakenEmote krakenEmote(emoteArrObj.toObject()); auto id = EmoteId{krakenEmote.id}; - auto code = EmoteName{krakenEmote.code}; + auto code = EmoteName{ + TwitchEmotes::cleanUpEmoteCode(krakenEmote.code)}; - auto cleanCode = - EmoteName{TwitchEmotes::cleanUpEmoteCode(code)}; - emoteSet->emotes.emplace_back( - TwitchEmote{id, cleanCode}); + emoteSet->emotes.emplace_back(TwitchEmote{id, code}); if (!emoteSet->local) { @@ -370,11 +368,11 @@ void TwitchAccount::loadUserstateEmotes() IvrEmote ivrEmote(emoteObj.toObject()); auto id = EmoteId{ivrEmote.id}; - auto code = EmoteName{ivrEmote.code}; - auto cleanCode = - EmoteName{TwitchEmotes::cleanUpEmoteCode(code)}; + auto code = EmoteName{ + TwitchEmotes::cleanUpEmoteCode(ivrEmote.code)}; + newUserEmoteSet->emotes.push_back( - TwitchEmote{id, cleanCode}); + TwitchEmote{id, code}); auto emote = getApp()->emotes->twitch.getOrCreateEmote(id, code); diff --git a/src/providers/twitch/TwitchEmotes.cpp b/src/providers/twitch/TwitchEmotes.cpp index cf8d091c5..38593a03a 100644 --- a/src/providers/twitch/TwitchEmotes.cpp +++ b/src/providers/twitch/TwitchEmotes.cpp @@ -12,9 +12,9 @@ TwitchEmotes::TwitchEmotes() { } -QString TwitchEmotes::cleanUpEmoteCode(const EmoteName &dirtyEmoteCode) +QString TwitchEmotes::cleanUpEmoteCode(const QString &dirtyEmoteCode) { - auto cleanCode = dirtyEmoteCode.string; + auto cleanCode = dirtyEmoteCode; cleanCode.detach(); static QMap emoteNameReplacements{ @@ -27,15 +27,12 @@ QString TwitchEmotes::cleanUpEmoteCode(const EmoteName &dirtyEmoteCode) {"R-?\\)", "R)"}, {"B-?\\)", "B)"}, }; - auto it = emoteNameReplacements.find(dirtyEmoteCode.string); + auto it = emoteNameReplacements.find(dirtyEmoteCode); if (it != emoteNameReplacements.end()) { cleanCode = it.value(); } - cleanCode.replace("<", "<"); - cleanCode.replace(">", ">"); - return cleanCode; } @@ -44,29 +41,7 @@ QString TwitchEmotes::cleanUpEmoteCode(const EmoteName &dirtyEmoteCode) EmotePtr TwitchEmotes::getOrCreateEmote(const EmoteId &id, const EmoteName &name_) { - static const QMap replacements{ - {"[oO](_|\\.)[oO]", "O_o"}, {"\\>\\;\\(", ">("}, - {"\\<\\;3", "<3"}, {"\\:-?(o|O)", ":O"}, - {"\\:-?(p|P)", ":P"}, {"\\:-?[\\\\/]", ":/"}, - {"\\:-?[z|Z|\\|]", ":Z"}, {"\\:-?\\(", ":("}, - {"\\:-?\\)", ":)"}, {"\\:-?D", ":D"}, - {"\\;-?(p|P)", ";P"}, {"\\;-?\\)", ";)"}, - {"R-?\\)", "R)"}, {"B-?\\)", "B)"}, - }; - - auto name = name_.string; - name.detach(); - - // replace < > - name.replace("<", "<"); - name.replace(">", ">"); - - // replace regexes - auto it = replacements.find(name); - if (it != replacements.end()) - { - name = it.value(); - } + auto name = TwitchEmotes::cleanUpEmoteCode(name_.string); // search in cache or create new emote auto cache = this->twitchEmotesCache_.access(); @@ -75,13 +50,13 @@ EmotePtr TwitchEmotes::getOrCreateEmote(const EmoteId &id, if (!shared) { (*cache)[id] = shared = std::make_shared(Emote{ - EmoteName{TwitchEmotes::cleanUpEmoteCode(EmoteName{name})}, + EmoteName{name}, ImageSet{ Image::fromUrl(getEmoteLink(id, "1.0"), 1), Image::fromUrl(getEmoteLink(id, "2.0"), 0.5), Image::fromUrl(getEmoteLink(id, "3.0"), 0.25), }, - Tooltip{name + "
Twitch Emote"}, + Tooltip{name.toHtmlEscaped() + "
Twitch Emote"}, Url{QString("https://twitchemotes.com/emotes/%1").arg(id.string)}}); } diff --git a/src/providers/twitch/TwitchEmotes.hpp b/src/providers/twitch/TwitchEmotes.hpp index 6ec826296..0f0234a47 100644 --- a/src/providers/twitch/TwitchEmotes.hpp +++ b/src/providers/twitch/TwitchEmotes.hpp @@ -36,7 +36,7 @@ struct CheerEmoteSet { class TwitchEmotes { public: - static QString cleanUpEmoteCode(const EmoteName &dirtyEmoteCode); + static QString cleanUpEmoteCode(const QString &dirtyEmoteCode); TwitchEmotes(); EmotePtr getOrCreateEmote(const EmoteId &id, const EmoteName &name);