From 7e59211fee6f3627df8bf49eaab1d1c2a77e9d9a Mon Sep 17 00:00:00 2001 From: JBBianchi Date: Thu, 2 May 2024 16:00:52 +0200 Subject: [PATCH] fix(Dashboard): Fixed "paging" in timeline, both length and offset handling of next "pages" --- .../CloudStreams.Dashboard/Components/Timeline/Store.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dashboard/CloudStreams.Dashboard/Components/Timeline/Store.cs b/src/dashboard/CloudStreams.Dashboard/Components/Timeline/Store.cs index b80e1263..c14e1b1f 100644 --- a/src/dashboard/CloudStreams.Dashboard/Components/Timeline/Store.cs +++ b/src/dashboard/CloudStreams.Dashboard/Components/Timeline/Store.cs @@ -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 { @@ -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); }