Skip to content

Commit 2557122

Browse files
committed
fix book list flickering
1 parent 4a8a61f commit 2557122

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

src/Web/BookStore.Web/Components/Pages/Home.razor

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
Class="mud-text-field-large" />
4444
</MudPaper>
4545

46-
@if (isLoading)
46+
@if (isLoading && pagedBooks == null)
4747
{
4848
<MudGrid>
4949
@for (int i = 0; i < 8; i++)
@@ -73,13 +73,29 @@
7373
else if (pagedBooks != null)
7474
{
7575
@* Results Info *@
76-
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-4">
77-
Showing @pagedBooks.Items.Count of @pagedBooks.TotalItemCount books
78-
@if (!string.IsNullOrWhiteSpace(searchQuery))
76+
<MudStack Row="true" AlignItems="AlignItems.Center" Class="mb-4">
77+
<MudText Typo="Typo.body2" Color="Color.Secondary">
78+
Showing @pagedBooks.Items.Count of @pagedBooks.TotalItemCount books
79+
@if (!string.IsNullOrWhiteSpace(searchQuery))
80+
{
81+
<MudChip T="string" Size="Size.Small" Color="Color.Primary" Class="ml-2">@searchQuery</MudChip>
82+
}
83+
</MudText>
84+
<MudSpacer />
85+
@if (isFetching)
7986
{
80-
<MudChip T="string" Size="Size.Small" Color="Color.Primary" Class="ml-2">@searchQuery</MudChip>
87+
<MudProgressCircular Color="Color.Primary" Size="Size.Small" Indeterminate="true" />
8188
}
82-
</MudText>
89+
</MudStack>
90+
91+
@if (isFetching)
92+
{
93+
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="mb-4" />
94+
}
95+
else
96+
{
97+
<div style="height: 4px;" class="mb-4"></div>
98+
}
8399

84100
@* Book Grid *@
85101
<MudGrid Spacing="4" Class="mb-6">
@@ -210,6 +226,7 @@
210226
private ReactiveQuery<BookStore.Client.PagedListDtoOfBookDto>? bookQuery;
211227
private BookStore.Client.PagedListDtoOfBookDto? pagedBooks => bookQuery?.Data;
212228
private bool isLoading => bookQuery?.IsLoading ?? true;
229+
private bool isFetching => bookQuery?.IsFetching ?? false;
213230
private string? errorMessage => bookQuery?.Error;
214231

215232
private string searchQuery = string.Empty;
@@ -305,7 +322,7 @@
305322
currentPage = 1;
306323
if (bookQuery != null)
307324
{
308-
await bookQuery.LoadAsync();
325+
await bookQuery.LoadAsync(silent: true);
309326
}
310327
}
311328

@@ -320,7 +337,7 @@
320337
currentPage = page;
321338
if (bookQuery != null)
322339
{
323-
await bookQuery.LoadAsync();
340+
await bookQuery.LoadAsync(silent: true);
324341
}
325342
}
326343

0 commit comments

Comments
 (0)