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:
@@ -56,12 +56,30 @@ namespace {
|
||||
std::pair<Outcome, EmoteMap> parseGlobalEmotes(
|
||||
const QJsonObject &jsonRoot, const EmoteMap ¤tEmotes)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user