Skip to content

Commit bdea318

Browse files
committed
Loading tweaks
1 parent f286fcd commit bdea318

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

Damselfly.Web.Client/Components/ImageBrowser/ImageGrid.razor

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999

100100
[Parameter] public GridImageSize CurrentGridSize { get; set; }
101101

102-
private bool NoResultsFound { get; set; } = true;
102+
private bool NoResultsFound { get; set; } = false;
103103

104104
protected override void OnInitialized()
105105
{
@@ -244,16 +244,22 @@
244244
// If we've tried to load data and there isn't any more, show the toast.
245245
toastClass = endOfImages ? "show" : string.Empty;
246246

247+
_ = AddImagesToGrid(response.MoreDataAvailable, cancelTokenSource.Token);
248+
}
249+
250+
private void ResetSearch()
251+
{
247252
// Cancel the old request, and start a new one
248253
cancelTokenSource.Cancel();
249254
cancelTokenSource.Dispose();
250255
cancelTokenSource = new CancellationTokenSource();
251-
252-
_ = AddImagesToGrid(response.MoreDataAvailable, cancelTokenSource.Token);
253256
}
254257

255-
protected void SearchQueryChanged()
258+
private void SearchQueryChanged()
256259
{
260+
// Abort any in-progress search results from being rendered
261+
ResetSearch();
262+
257263
selectionService.ClearSelection();
258264
gridImages.Clear();
259265
endOfImages = false;
@@ -289,16 +295,15 @@
289295

290296
foreach( var set in chunks )
291297
{
292-
// Another refresh, hot on our heels, is cancelling this one
293-
if( token.IsCancellationRequested )
294-
return;
295-
296298
StateHasChanged();
297299

298300
var toAdd = set.ExceptBy(gridImages.Select(x => x.ImageId), x => x).ToList();
299-
300301
var images = await imageCache.GetCachedImages(toAdd);
301302

303+
// Check if we had a cancellation request while we pulled back the images. If so, abort
304+
if( token.IsCancellationRequested )
305+
return;
306+
302307
if(images.Any())
303308
{
304309
gridImages.AddRange(images);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
const CACHE_VERSION='4.2.1-20241230223619'
1+
const CACHE_VERSION='4.2.1-20241231092916'

0 commit comments

Comments
 (0)