removed old NetworkRequest api
This commit is contained in:
+42
-43
@@ -213,48 +213,47 @@ void Toasts::fetchChannelAvatar(const QString channelName,
|
||||
QString requestUrl("https://api.twitch.tv/kraken/users?login=" +
|
||||
channelName);
|
||||
|
||||
NetworkRequest request(requestUrl);
|
||||
request.setCaller(QThread::currentThread());
|
||||
request.makeAuthorizedV5(getDefaultClientID());
|
||||
request.setTimeout(30000);
|
||||
request.onSuccess([successCallback](auto result) mutable -> Outcome {
|
||||
auto root = result.parseJson();
|
||||
if (!root.value("users").isArray())
|
||||
{
|
||||
// log("API Error while getting user id, users is not an array");
|
||||
successCallback("");
|
||||
return Failure;
|
||||
}
|
||||
auto users = root.value("users").toArray();
|
||||
if (users.size() != 1)
|
||||
{
|
||||
// log("API Error while getting user id, users array size is not
|
||||
// 1");
|
||||
successCallback("");
|
||||
return Failure;
|
||||
}
|
||||
if (!users[0].isObject())
|
||||
{
|
||||
// log("API Error while getting user id, first user is not an
|
||||
// object");
|
||||
successCallback("");
|
||||
return Failure;
|
||||
}
|
||||
auto firstUser = users[0].toObject();
|
||||
auto avatar = firstUser.value("logo");
|
||||
if (!avatar.isString())
|
||||
{
|
||||
// log("API Error: while getting user avatar, first user object "
|
||||
// "`avatar` key "
|
||||
// "is not a "
|
||||
// "string");
|
||||
successCallback("");
|
||||
return Failure;
|
||||
}
|
||||
successCallback(avatar.toString());
|
||||
return Success;
|
||||
});
|
||||
|
||||
request.execute();
|
||||
NetworkRequest(requestUrl)
|
||||
.caller(QThread::currentThread())
|
||||
.authorizeTwitchV5(getDefaultClientID())
|
||||
.timeout(30000)
|
||||
.onSuccess([successCallback](auto result) mutable -> Outcome {
|
||||
auto root = result.parseJson();
|
||||
if (!root.value("users").isArray())
|
||||
{
|
||||
// log("API Error while getting user id, users is not an array");
|
||||
successCallback("");
|
||||
return Failure;
|
||||
}
|
||||
auto users = root.value("users").toArray();
|
||||
if (users.size() != 1)
|
||||
{
|
||||
// log("API Error while getting user id, users array size is not
|
||||
// 1");
|
||||
successCallback("");
|
||||
return Failure;
|
||||
}
|
||||
if (!users[0].isObject())
|
||||
{
|
||||
// log("API Error while getting user id, first user is not an
|
||||
// object");
|
||||
successCallback("");
|
||||
return Failure;
|
||||
}
|
||||
auto firstUser = users[0].toObject();
|
||||
auto avatar = firstUser.value("logo");
|
||||
if (!avatar.isString())
|
||||
{
|
||||
// log("API Error: while getting user avatar, first user object "
|
||||
// "`avatar` key "
|
||||
// "is not a "
|
||||
// "string");
|
||||
successCallback("");
|
||||
return Failure;
|
||||
}
|
||||
successCallback(avatar.toString());
|
||||
return Success;
|
||||
})
|
||||
.execute();
|
||||
}
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user