diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e8e2bcab..338f434b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/providers/twitch/api/Helix.cpp b/src/providers/twitch/api/Helix.cpp index 7ed8794bd..3b0ba491d 100644 --- a/src/providers/twitch/api/Helix.cpp +++ b/src/providers/twitch/api/Helix.cpp @@ -2078,31 +2078,32 @@ void Helix::getChatters( auto finalChatters = std::make_shared(); - ResultCallback 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