Fix recursive fetchChatters call (#4097)

This commit is contained in:
pajlada 2022-11-02 10:31:28 +01:00 committed by GitHub
parent 7640677a43
commit 4196bba4ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 20 deletions

View file

@ -69,7 +69,7 @@
- Minor: Migrated /uniquechatoff and /r9kbetaoff to Helix API. (#4057)
- Minor: Added stream titles to windows live toast notifications. (#1297)
- Minor: Make menus and placeholders display appropriate custom key combos. (#4045)
- Minor: Migrated /chatters to Helix API. (#4088)
- Minor: Migrated /chatters to Helix API. (#4088, #4097)
- Minor: Add settings tooltips. (#3437)
- Bugfix: Connection to Twitch PubSub now recovers more reliably. (#3643, #3716)
- Bugfix: Fixed `Smooth scrolling on new messages` setting sometimes hiding messages. (#4028)

View file

@ -2078,31 +2078,32 @@ void Helix::getChatters(
auto finalChatters = std::make_shared<HelixChatters>();
ResultCallback<HelixChatters> fetchSuccess;
auto fetchSuccess = [this, broadcasterID, moderatorID, maxChattersToFetch,
finalChatters, successCallback,
failureCallback](auto fs) {
return [=](auto chatters) {
qCDebug(chatterinoTwitch)
<< "Fetched" << chatters.chatters.size() << "chatters";
finalChatters->chatters.merge(chatters.chatters);
finalChatters->total = chatters.total;
fetchSuccess = [this, broadcasterID, moderatorID, maxChattersToFetch,
finalChatters, &fetchSuccess, successCallback,
failureCallback](auto chatters) {
qCDebug(chatterinoTwitch)
<< "Fetched" << chatters.chatters.size() << "chatters";
finalChatters->chatters.merge(chatters.chatters);
finalChatters->total = chatters.total;
if (chatters.cursor.isEmpty() ||
finalChatters->chatters.size() >= maxChattersToFetch)
{
// Done paginating
successCallback(*finalChatters);
return;
}
if (chatters.cursor.isEmpty() ||
finalChatters->chatters.size() >= maxChattersToFetch)
{
// Done paginating
successCallback(*finalChatters);
return;
}
this->fetchChatters(broadcasterID, moderatorID, NUM_CHATTERS_TO_FETCH,
chatters.cursor, fetchSuccess, failureCallback);
this->fetchChatters(broadcasterID, moderatorID,
NUM_CHATTERS_TO_FETCH, chatters.cursor, fs,
failureCallback);
};
};
// Initiate the recursive calls
this->fetchChatters(broadcasterID, moderatorID, NUM_CHATTERS_TO_FETCH, "",
fetchSuccess, failureCallback);
fetchSuccess(fetchSuccess), failureCallback);
}
// List the VIPs of a channel