Split parseChannelResponse into two functions: parseModBadge and
parseChannelEmotes
This commit is contained in:
@@ -79,12 +79,11 @@ namespace {
|
|||||||
|
|
||||||
return {Success, std::move(emotes)};
|
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;
|
boost::optional<EmotePtr> modBadge;
|
||||||
|
|
||||||
// Parse mod badge
|
|
||||||
auto room = jsonRoot.value("room").toObject();
|
auto room = jsonRoot.value("room").toObject();
|
||||||
auto modUrls = room.value("mod_urls").toObject();
|
auto modUrls = room.value("mod_urls").toObject();
|
||||||
if (!modUrls.isEmpty())
|
if (!modUrls.isEmpty())
|
||||||
@@ -108,8 +107,11 @@ namespace {
|
|||||||
modBadge1x,
|
modBadge1x,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
return modBadge;
|
||||||
|
}
|
||||||
|
|
||||||
// Parse emotes
|
EmoteMap parseChannelEmotes(const QJsonObject &jsonRoot)
|
||||||
|
{
|
||||||
auto jsonSets = jsonRoot.value("sets").toObject();
|
auto jsonSets = jsonRoot.value("sets").toObject();
|
||||||
auto emotes = EmoteMap();
|
auto emotes = EmoteMap();
|
||||||
|
|
||||||
@@ -139,7 +141,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {Success, std::move(emotes), modBadge};
|
return emotes;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@@ -192,17 +194,14 @@ void FfzEmotes::loadChannel(
|
|||||||
.onSuccess([emoteCallback = std::move(emoteCallback),
|
.onSuccess([emoteCallback = std::move(emoteCallback),
|
||||||
modBadgeCallback =
|
modBadgeCallback =
|
||||||
std::move(modBadgeCallback)](auto result) -> Outcome {
|
std::move(modBadgeCallback)](auto result) -> Outcome {
|
||||||
auto [success, emoteMap, modBadge] =
|
auto json = result.parseJson();
|
||||||
parseChannelResponse(result.parseJson());
|
auto emoteMap = parseChannelEmotes(json);
|
||||||
if (!success)
|
auto modBadge = parseModBadge(json);
|
||||||
{
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
emoteCallback(std::move(emoteMap));
|
emoteCallback(std::move(emoteMap));
|
||||||
modBadgeCallback(std::move(modBadge));
|
modBadgeCallback(std::move(modBadge));
|
||||||
|
|
||||||
return success;
|
return Success;
|
||||||
})
|
})
|
||||||
.onError([channelId](int result) {
|
.onError([channelId](int result) {
|
||||||
if (result == 203)
|
if (result == 203)
|
||||||
|
|||||||
Reference in New Issue
Block a user