From 9f2fc909289a2fe4ffffc5f6809516cabc63dd51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82?= Date: Sat, 17 Jul 2021 21:33:03 +0200 Subject: [PATCH] Fix crash and completion in other special channels than /whispers (#3033) --- CHANGELOG.md | 2 +- src/widgets/splits/InputCompletionPopup.cpp | 17 +++++++++-------- src/widgets/splits/SplitInput.cpp | 3 +-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76e842cc..ecd3acb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## Unversioned - Major: Newly uploaded Twitch emotes are once again present in emote picker and can be autocompleted with Tab as well. (#2992) -- Minor: Added autocompletion in /whispers for Twitch emotes, Global Bttv/Ffz emotes and emojis. (#2999) +- Minor: Added autocompletion in /whispers for Twitch emotes, Global Bttv/Ffz emotes and emojis. (#2999, #3033) - Minor: Received Twitch messages now use the exact same timestamp (obtained from Twitch's server) for every Chatterino user instead of assuming message timestamp on client's side. (#3021) - Minor: Received IRC messages use `time` message tag for timestamp if it's available. (#3021) - Bugfix: Fixed "smiley" emotes being unable to be "Tabbed" with autocompletion, introduced in v2.3.3. (#3010) diff --git a/src/widgets/splits/InputCompletionPopup.cpp b/src/widgets/splits/InputCompletionPopup.cpp index b1714a5d..1badc894 100644 --- a/src/widgets/splits/InputCompletionPopup.cpp +++ b/src/widgets/splits/InputCompletionPopup.cpp @@ -75,8 +75,8 @@ void InputCompletionPopup::updateEmotes(const QString &text, ChannelPtr channel) { std::vector<_Emote> emotes; auto tc = dynamic_cast(channel.get()); - auto wc = channel.get()->getType() == Channel::Type::TwitchWhispers; - if (tc || wc) + // returns true also for special Twitch channels (/live, /mentions, /whispers, etc.) + if (channel->isTwitchChannel()) { if (auto user = getApp()->accounts->twitch.getCurrent()) { @@ -86,7 +86,8 @@ void InputCompletionPopup::updateEmotes(const QString &text, ChannelPtr channel) // Twitch Emotes available locally auto localEmoteData = user->accessLocalEmotes(); - if (localEmoteData->find(tc->roomId()) != localEmoteData->end()) + if (tc && + localEmoteData->find(tc->roomId()) != localEmoteData->end()) { if (auto localEmotes = &localEmoteData->at(tc->roomId())) { @@ -103,13 +104,13 @@ void InputCompletionPopup::updateEmotes(const QString &text, ChannelPtr channel) addEmotes(emotes, *bttv, text, "Channel BetterTTV"); if (auto ffz = tc->ffzEmotes()) addEmotes(emotes, *ffz, text, "Channel FrankerFaceZ"); - - if (auto bttvG = getApp()->twitch2->getBttvEmotes().emotes()) - addEmotes(emotes, *bttvG, text, "Global BetterTTV"); - if (auto ffzG = getApp()->twitch2->getFfzEmotes().emotes()) - addEmotes(emotes, *ffzG, text, "Global FrankerFaceZ"); } + if (auto bttvG = getApp()->twitch2->getBttvEmotes().emotes()) + addEmotes(emotes, *bttvG, text, "Global BetterTTV"); + if (auto ffzG = getApp()->twitch2->getFfzEmotes().emotes()) + addEmotes(emotes, *ffzG, text, "Global FrankerFaceZ"); + addEmojis(emotes, getApp()->emotes->emojis.emojis, text); } diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index 16cb2317..96cbafd8 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -464,8 +464,7 @@ void SplitInput::updateCompletionPopup() auto channel = this->split_->getChannel().get(); auto tc = dynamic_cast(channel); bool showEmoteCompletion = - getSettings()->emoteCompletionWithColon && - (tc || (channel->getType() == Channel::Type::TwitchWhispers)); + channel->isTwitchChannel() && getSettings()->emoteCompletionWithColon; bool showUsernameCompletion = tc && getSettings()->showUsernameCompletionMenu; if (!showEmoteCompletion && !showUsernameCompletion)