From 94048595f6c034587f05454a5ea77751787ef45e Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sun, 8 Sep 2019 13:57:24 +0200 Subject: [PATCH] Split parseChannelResponse into two functions: parseModBadge and parseChannelEmotes --- src/providers/ffz/FfzEmotes.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/providers/ffz/FfzEmotes.cpp b/src/providers/ffz/FfzEmotes.cpp index 6b74657ab..f25d03feb 100644 --- a/src/providers/ffz/FfzEmotes.cpp +++ b/src/providers/ffz/FfzEmotes.cpp @@ -79,12 +79,11 @@ namespace { return {Success, std::move(emotes)}; } - std::tuple> - parseChannelResponse(const QJsonObject &jsonRoot) + + boost::optional parseModBadge(const QJsonObject &jsonRoot) { boost::optional 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)