mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Split parseChannelResponse into two functions: parseModBadge and
parseChannelEmotes
This commit is contained in:
parent
862164bc2b
commit
94048595f6
1 changed files with 11 additions and 12 deletions
|
@ -79,12 +79,11 @@ namespace {
|
|||
|
||||
return {Success, std::move(emotes)};
|
||||
}
|
||||
std::tuple<Outcome, EmoteMap, boost::optional<EmotePtr>>
|
||||
parseChannelResponse(const QJsonObject &jsonRoot)
|
||||
|
||||
boost::optional<EmotePtr> parseModBadge(const QJsonObject &jsonRoot)
|
||||
{
|
||||
boost::optional<EmotePtr> modBadge;
|
||||
|
||||
// Parse mod badge
|
||||
auto room = jsonRoot.value("room").toObject();
|
||||
auto modUrls = room.value("mod_urls").toObject();
|
||||
if (!modUrls.isEmpty())
|
||||
|
@ -108,8 +107,11 @@ namespace {
|
|||
modBadge1x,
|
||||
});
|
||||
}
|
||||
return modBadge;
|
||||
}
|
||||
|
||||
// Parse emotes
|
||||
EmoteMap parseChannelEmotes(const QJsonObject &jsonRoot)
|
||||
{
|
||||
auto jsonSets = jsonRoot.value("sets").toObject();
|
||||
auto emotes = EmoteMap();
|
||||
|
||||
|
@ -139,7 +141,7 @@ namespace {
|
|||
}
|
||||
}
|
||||
|
||||
return {Success, std::move(emotes), modBadge};
|
||||
return emotes;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
@ -192,17 +194,14 @@ void FfzEmotes::loadChannel(
|
|||
.onSuccess([emoteCallback = std::move(emoteCallback),
|
||||
modBadgeCallback =
|
||||
std::move(modBadgeCallback)](auto result) -> Outcome {
|
||||
auto [success, emoteMap, modBadge] =
|
||||
parseChannelResponse(result.parseJson());
|
||||
if (!success)
|
||||
{
|
||||
return success;
|
||||
}
|
||||
auto json = result.parseJson();
|
||||
auto emoteMap = parseChannelEmotes(json);
|
||||
auto modBadge = parseModBadge(json);
|
||||
|
||||
emoteCallback(std::move(emoteMap));
|
||||
modBadgeCallback(std::move(modBadge));
|
||||
|
||||
return success;
|
||||
return Success;
|
||||
})
|
||||
.onError([channelId](int result) {
|
||||
if (result == 203)
|
||||
|
|
Loading…
Reference in a new issue