Skip to content

Commit

Permalink
fix(Dashboard): Fixed "paging" in timeline, both length and offset ha…
Browse files Browse the repository at this point in the history
…ndling of next "pages"
  • Loading branch information
JBBianchi committed May 2, 2024
1 parent 7e9c65a commit 7e59211
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public async Task GatherCloudEventsAsync()
else
{
bool fetchMore = true;
ulong length = StreamReadOptions.MaxLength;
long offset = options.Offset ?? (options.Direction == StreamReadDirection.Forwards ? 0 : -1);
do
{
Expand All @@ -184,12 +185,13 @@ public async Task GatherCloudEventsAsync()
Direction = options.Direction,
Partition = options.Partition,
Offset = offset,
Length = StreamReadOptions.MaxLength
Length = length
};
var cloudEvents = await (await cloudStreamsApi.CloudEvents.Stream.ReadStreamAsync(readOptions, this.CancellationTokenSource.Token).ConfigureAwait(false)).ToListAsync().ConfigureAwait(false);
data.AddRange(cloudEvents!);
offset = (long)cloudEvents.Last()!.GetSequence()!;
fetchMore = cloudEvents.Count > 1 && (ulong)data.Count < options!.Length;
offset = (long)cloudEvents.Last()!.GetSequence()! + (options.Direction == StreamReadDirection.Forwards ? 1 : -1);
length = Math.Min(options!.Length - (ulong)data.Count, StreamReadOptions.MaxLength);
fetchMore = cloudEvents.Count > 1 && length != 0;
}
while(fetchMore);
}
Expand Down

0 comments on commit 7e59211

Please sign in to comment.