From 3e2116629a53322451ca02627e8f67e7ba64b147 Mon Sep 17 00:00:00 2001 From: nerix Date: Sun, 13 Oct 2024 12:08:32 +0200 Subject: [PATCH] chore: improve appearance of Twitch emotes in popup (#5632) --- CHANGELOG.md | 2 +- src/providers/twitch/TwitchEmotes.cpp | 15 ++++++--------- src/widgets/dialogs/EmotePopup.cpp | 25 ++++++++++++++++--------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a8b5eaa4..2c71db4ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,7 +49,7 @@ - Bugfix: Fixed splits staying paused after unfocusing Chatterino in certain configurations. (#5504, #5637) - Bugfix: Links with invalid characters in the domain are no longer detected. (#5509) - Bugfix: Fixed janky selection for messages with RTL segments (selection is still wrong, but consistently wrong). (#5525) -- Bugfix: Fixed event emotes not showing up in autocomplete and popups. (#5239, #5580, #5582) +- Bugfix: Fixed event emotes not showing up in autocomplete and popups. (#5239, #5580, #5582, #5632) - Bugfix: Fixed tab visibility being controllable in the emote popup. (#5530) - Bugfix: Fixed account switch not being saved if no other settings were changed. (#5558) - Bugfix: Fixed some tooltips not being readable. (#5578) diff --git a/src/providers/twitch/TwitchEmotes.cpp b/src/providers/twitch/TwitchEmotes.cpp index 3389a43ed..005aff341 100644 --- a/src/providers/twitch/TwitchEmotes.cpp +++ b/src/providers/twitch/TwitchEmotes.cpp @@ -494,17 +494,14 @@ TwitchEmoteSetMeta getTwitchEmoteSetMeta(const HelixChannelEmote &emote) return u"x-c2-globals"_s; } - if (!emote.setID.isEmpty()) + // some bit emote-sets have an id, but we want to combine them into a + // single set + if (isBits) { - return emote.setID; + return TWITCH_BIT_EMOTE_SET_PREFIX % emote.ownerID; } - - if (isSub) - { - return TWITCH_SUB_EMOTE_SET_PREFIX % emote.ownerID; - } - // isBits - return TWITCH_BIT_EMOTE_SET_PREFIX % emote.ownerID; + // isSub + return TWITCH_SUB_EMOTE_SET_PREFIX % emote.ownerID; }(); return { diff --git a/src/widgets/dialogs/EmotePopup.cpp b/src/widgets/dialogs/EmotePopup.cpp index 8b62b0e02..02a98bde2 100644 --- a/src/widgets/dialogs/EmotePopup.cpp +++ b/src/widgets/dialogs/EmotePopup.cpp @@ -136,25 +136,32 @@ void addTwitchEmoteSets(const std::shared_ptr &local, MessageElementFlag::TwitchEmote); } - // Put current channel emotes at the top + std::vector< + std::pair>> + sortedSets; + sortedSets.reserve(sets->size()); for (const auto &[_id, set] : *sets) { if (set.owner->id == currentChannelID) { + // Put current channel emotes at the top addEmotes(subChannel, set.emotes, set.title(), MessageElementFlag::TwitchEmote); } + else + { + sortedSets.emplace_back(set.title(), std::cref(set)); + } } - for (const auto &[id, set] : *sets) - { - if (set.owner->id == currentChannelID) - { - continue; - } + std::ranges::sort(sortedSets, [](const auto &a, const auto &b) { + return a.first.compare(b.first, Qt::CaseInsensitive) < 0; + }); - addEmotes(set.isSubLike ? subChannel : globalChannel, set.emotes, - set.title(), MessageElementFlag::TwitchEmote); + for (const auto &[title, set] : sortedSets) + { + addEmotes(set.get().isSubLike ? subChannel : globalChannel, + set.get().emotes, title, MessageElementFlag::TwitchEmote); } }