Skip to content

Commit

Permalink
fix(Dashboard): Fixed a bug both in the list and timeline views when …
Browse files Browse the repository at this point in the history
…displaying a stream containing only one event.
  • Loading branch information
JBBianchi committed Apr 15, 2024
1 parent 808414f commit 6e659e0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@
}
var start = entries.First().Time!.Value;
var end = entries.Last().Time!.Value;
var margin = end.Subtract(start).TotalMilliseconds / 20;
var delta = end.Subtract(start).TotalMilliseconds;
if (delta == 0)
{
delta = 20;
}
var margin = delta / 20;
await this.eventDropsInterop.RenderTimelineAsync(this.timeline, this.dotnetReference, timelineLanes, start, end.AddMilliseconds(margin));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public async ValueTask<ItemsProviderResult<CloudEvent>> ProvideCloudEvents(Items
{
readOptions = readOptions with { Partition = null };
}
var totalCount = (int?)this.Get(state => state.TotalCount) ?? 100;
var totalCount = (int?)this.Get(state => state.TotalCount) ?? 0;
if (readOptions.Direction == StreamReadDirection.Forwards)
{
readOptions.Offset = (readOptions.Offset ?? 0) + request.StartIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@
Offcanvas? offcanvas;
ReadOptionsForm? readOptionForm;
Virtualize<CloudEvent>? virtualize;
bool readOptionsInitialized = false;

/// <inheritdoc/>
protected override async Task OnInitializedAsync()
Expand All @@ -121,7 +120,7 @@
(_, _) => true
)
.Throttle(TimeSpan.FromMilliseconds(300))
.SubscribeAsync(this.OnReadOptionChangedAsync, null, null, cancellationToken: this.CancellationTokenSource.Token);
.SubscribeAsync(this.OnReadOptionChangedAsync, null!, null!, cancellationToken: this.CancellationTokenSource.Token);
}

/// <summary>
Expand All @@ -139,11 +138,6 @@
/// </summary>
private async Task OnReadOptionChangedAsync(bool _)
{
if (!this.readOptionsInitialized)
{
this.readOptionsInitialized = true;
return;
}
if (this.virtualize != null)
{
await this.virtualize.RefreshDataAsync();
Expand Down

0 comments on commit 6e659e0

Please sign in to comment.