Fix large blocked users list preventing login (#175)

* Remove await from get blocked users

* Implement request limit to blocked users
This commit is contained in:
Tommy Chow 2022-08-05 03:24:35 -04:00 • committed by GitHub
parent d2c57921b8
commit 08d476d11e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -410,6 +410,12 @@ class TwitchApi {
final result = blockedList.map((e) => UserBlockedTwitch.fromJson(e)).toList();
if (cursor != null) {
// Wait a bit (150 milliseconds) before recursively calling.
// This will prevent going over the rate limit to due a massive blocked users list.
//
// With the Twitch API, we can make up to 800 requests per minute.
// Waiting 150 milliseconds between requests will cap the rate here at 400 requests per minute.
await Future.delayed(const Duration(milliseconds: 150));
result.addAll(await getUserBlockedList(id: id, cursor: cursor, headers: headers));
}