Ensure live status requests are always batched (#4713)
This commit is contained in:
@@ -417,6 +417,45 @@ void Helix::createClip(QString channelId,
|
||||
.execute();
|
||||
}
|
||||
|
||||
void Helix::fetchChannels(
|
||||
QStringList userIDs,
|
||||
ResultCallback<std::vector<HelixChannel>> successCallback,
|
||||
HelixFailureCallback failureCallback)
|
||||
{
|
||||
QUrlQuery urlQuery;
|
||||
|
||||
for (const auto &userID : userIDs)
|
||||
{
|
||||
urlQuery.addQueryItem("broadcaster_id", userID);
|
||||
}
|
||||
|
||||
this->makeGet("channels", urlQuery)
|
||||
.onSuccess([successCallback, failureCallback](auto result) -> Outcome {
|
||||
auto root = result.parseJson();
|
||||
auto data = root.value("data");
|
||||
|
||||
if (!data.isArray())
|
||||
{
|
||||
failureCallback();
|
||||
return Failure;
|
||||
}
|
||||
|
||||
std::vector<HelixChannel> channels;
|
||||
|
||||
for (const auto &unparsedChannel : data.toArray())
|
||||
{
|
||||
channels.emplace_back(unparsedChannel.toObject());
|
||||
}
|
||||
|
||||
successCallback(channels);
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto /*result*/) {
|
||||
failureCallback();
|
||||
})
|
||||
.execute();
|
||||
}
|
||||
|
||||
void Helix::getChannel(QString broadcasterId,
|
||||
ResultCallback<HelixChannel> successCallback,
|
||||
HelixFailureCallback failureCallback)
|
||||
|
||||
@@ -788,6 +788,12 @@ public:
|
||||
std::function<void(HelixClipError)> failureCallback,
|
||||
std::function<void()> finallyCallback) = 0;
|
||||
|
||||
// https://dev.twitch.tv/docs/api/reference#get-channel-information
|
||||
virtual void fetchChannels(
|
||||
QStringList userIDs,
|
||||
ResultCallback<std::vector<HelixChannel>> successCallback,
|
||||
HelixFailureCallback failureCallback) = 0;
|
||||
|
||||
// https://dev.twitch.tv/docs/api/reference#get-channel-information
|
||||
virtual void getChannel(QString broadcasterId,
|
||||
ResultCallback<HelixChannel> successCallback,
|
||||
@@ -1101,6 +1107,12 @@ public:
|
||||
std::function<void(HelixClipError)> failureCallback,
|
||||
std::function<void()> finallyCallback) final;
|
||||
|
||||
// https://dev.twitch.tv/docs/api/reference#get-channel-information
|
||||
void fetchChannels(
|
||||
QStringList userIDs,
|
||||
ResultCallback<std::vector<HelixChannel>> successCallback,
|
||||
HelixFailureCallback failureCallback) final;
|
||||
|
||||
// https://dev.twitch.tv/docs/api/reference#get-channel-information
|
||||
void getChannel(QString broadcasterId,
|
||||
ResultCallback<HelixChannel> successCallback,
|
||||
|
||||
@@ -43,7 +43,7 @@ URL: https://dev.twitch.tv/docs/api/reference#get-streams
|
||||
|
||||
Used in:
|
||||
|
||||
- `TwitchChannel` to get live status, game, title, and viewer count of a channel
|
||||
- `LiveController` to get live status, game, title, and viewer count of a channel
|
||||
- `NotificationController` to provide notifications for channels you might not have open in Chatterino, but are still interested in getting notifications for
|
||||
|
||||
### Create Clip
|
||||
@@ -61,7 +61,7 @@ URL: https://dev.twitch.tv/docs/api/reference#get-channel-information
|
||||
|
||||
Used in:
|
||||
|
||||
- `TwitchChannel` to refresh stream title
|
||||
- `LiveController` to refresh stream title & display name
|
||||
|
||||
### Update Channel
|
||||
|
||||
|
||||
Reference in New Issue
Block a user