Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a bug both in the list and timeline views when displaying a stream containing only one event #56

Merged
merged 1 commit into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
await base.OnInitializedAsync().ConfigureAwait(false);
this.Store.StreamsReadOptions.Subscribe(streamsReadOptions => this.OnStateChanged(cmp => cmp.streamsReadOptions = streamsReadOptions), token: this.CancellationTokenSource.Token);
this.Store.Loading.Subscribe(processing => this.OnStateChanged(cmp => cmp.loading = processing), token: this.CancellationTokenSource.Token);
this.Store.TimelineLanes.SubscribeAsync(async timelineLanes => await this.RenderTimelineAsync(timelineLanes), null, null, cancellationToken: this.CancellationTokenSource.Token);

Check warning on line 134 in src/dashboard/CloudStreams.Dashboard/Components/Timeline/Timeline.razor

View workflow job for this annotation

GitHub Actions / build (8.0.x)

Cannot convert null literal to non-nullable reference type.

Check warning on line 134 in src/dashboard/CloudStreams.Dashboard/Components/Timeline/Timeline.razor

View workflow job for this annotation

GitHub Actions / build (8.0.x)

Cannot convert null literal to non-nullable reference type.

}

Expand Down 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
Loading