Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Modio/Clients/SearchClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public async IAsyncEnumerable<T> ToEnumerable()
public async IAsyncEnumerable<IReadOnlyList<T>> ToPagedEnumerable()
{
var (method, path) = this.route;
uint? remaining = null;
// Huge integer type that does signed arithmetic and encompasses uint's max value
long? remaining = null;
do
{
var req = new Request(method, path);
Expand All @@ -93,6 +94,10 @@ public async IAsyncEnumerable<IReadOnlyList<T>> ToPagedEnumerable()
remaining ??= result.Total;
remaining -= result.Count;

// Don't bother returning anything or continuing for an empty response
if (result.Count == 0)
yield break;

var limit = result.Limit;
var offset = result.Offset;

Expand Down
Loading