chore: improve appearance of Twitch emotes in popup (#5632)

This commit is contained in:
nerix 2024-10-13 12:08:32 +02:00 committed by GitHub
parent 64864a0901
commit 3e2116629a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 19 deletions

View file

@ -49,7 +49,7 @@
- Bugfix: Fixed splits staying paused after unfocusing Chatterino in certain configurations. (#5504, #5637) - 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: 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 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 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 account switch not being saved if no other settings were changed. (#5558)
- Bugfix: Fixed some tooltips not being readable. (#5578) - Bugfix: Fixed some tooltips not being readable. (#5578)

View file

@ -494,17 +494,14 @@ TwitchEmoteSetMeta getTwitchEmoteSetMeta(const HelixChannelEmote &emote)
return u"x-c2-globals"_s; 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;
}
if (isSub)
{
return TWITCH_SUB_EMOTE_SET_PREFIX % emote.ownerID;
}
// isBits
return TWITCH_BIT_EMOTE_SET_PREFIX % emote.ownerID; return TWITCH_BIT_EMOTE_SET_PREFIX % emote.ownerID;
}
// isSub
return TWITCH_SUB_EMOTE_SET_PREFIX % emote.ownerID;
}(); }();
return { return {

View file

@ -136,25 +136,32 @@ void addTwitchEmoteSets(const std::shared_ptr<const EmoteMap> &local,
MessageElementFlag::TwitchEmote); MessageElementFlag::TwitchEmote);
} }
// Put current channel emotes at the top std::vector<
std::pair<QString, std::reference_wrapper<const TwitchEmoteSet>>>
sortedSets;
sortedSets.reserve(sets->size());
for (const auto &[_id, set] : *sets) for (const auto &[_id, set] : *sets)
{ {
if (set.owner->id == currentChannelID) if (set.owner->id == currentChannelID)
{ {
// Put current channel emotes at the top
addEmotes(subChannel, set.emotes, set.title(), addEmotes(subChannel, set.emotes, set.title(),
MessageElementFlag::TwitchEmote); MessageElementFlag::TwitchEmote);
} }
else
{
sortedSets.emplace_back(set.title(), std::cref(set));
}
} }
for (const auto &[id, set] : *sets) std::ranges::sort(sortedSets, [](const auto &a, const auto &b) {
{ return a.first.compare(b.first, Qt::CaseInsensitive) < 0;
if (set.owner->id == currentChannelID) });
{
continue;
}
addEmotes(set.isSubLike ? subChannel : globalChannel, set.emotes, for (const auto &[title, set] : sortedSets)
set.title(), MessageElementFlag::TwitchEmote); {
addEmotes(set.get().isSubLike ? subChannel : globalChannel,
set.get().emotes, title, MessageElementFlag::TwitchEmote);
} }
} }