Ensure live status requests are always batched (#4713)

This commit is contained in:
pajlada
2023-07-02 15:52:15 +02:00
committed by GitHub
parent f915eab1a2
commit 76527073cf
20 changed files with 582 additions and 282 deletions
+39
View File
@@ -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)
+12
View File
@@ -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,
+2 -2
View File
@@ -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