Fix usage of FrankerFaceZ global emote API (#3921)

We no longer blindly parse all sets as global emotes, but rather match them against the default_sets as intended.

This means that some emotes will no longer be visible through Chatterino (e.g. AndKnuckles). This is more in line with how the FrankerFaceZ browser extension works.
This commit is contained in:
pajlada 2022-10-01 13:42:05 +02:00 committed by GitHub
parent d024a1ef7e
commit 5e02fdab52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View file

@ -66,6 +66,7 @@
- Bugfix: Fixed crash related to logging IRC channels (#3918)
- Bugfix: Mentions of "You" in timeouts will link to your own user now instead of the user "You". (#3922)
- Bugfix: Fixed emoji popup not being shown in IRC channels (#4021)
- Bugfix: Fixed non-global FrankerFaceZ emotes from being loaded as global emotes. (#3921)
- Dev: Removed official support for QMake. (#3839, #3883)
- Dev: Rewrote LimitedQueue (#3798)
- Dev: Overhauled highlight system by moving all checks into a Controller allowing for easier tests. (#3399, #3801, #3835)

View file

@ -56,12 +56,30 @@ namespace {
std::pair<Outcome, EmoteMap> parseGlobalEmotes(
const QJsonObject &jsonRoot, const EmoteMap &currentEmotes)
{
// Load default sets from the `default_sets` object
std::unordered_set<int> defaultSets{};
auto jsonDefaultSets = jsonRoot.value("default_sets").toArray();
for (auto jsonDefaultSet : jsonDefaultSets)
{
defaultSets.insert(jsonDefaultSet.toInt());
}
auto jsonSets = jsonRoot.value("sets").toObject();
auto emotes = EmoteMap();
for (auto jsonSet : jsonSets)
{
auto jsonEmotes = jsonSet.toObject().value("emoticons").toArray();
auto jsonSetObject = jsonSet.toObject();
const auto emoteSetID = jsonSetObject.value("id").toInt();
if (defaultSets.find(emoteSetID) == defaultSets.end())
{
qCDebug(chatterinoFfzemotes)
<< "Skipping global emote set" << emoteSetID
<< "as it's not part of the default sets";
continue;
}
auto jsonEmotes = jsonSetObject.value("emoticons").toArray();
for (auto jsonEmoteValue : jsonEmotes)
{