Skip to content

Commit

Permalink
Loading tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Webreaper committed Dec 31, 2024
1 parent f286fcd commit bdea318
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 14 additions & 9 deletions Damselfly.Web.Client/Components/ImageBrowser/ImageGrid.razor
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@

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

private bool NoResultsFound { get; set; } = true;
private bool NoResultsFound { get; set; } = false;

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

_ = AddImagesToGrid(response.MoreDataAvailable, cancelTokenSource.Token);
}

private void ResetSearch()
{
// Cancel the old request, and start a new one
cancelTokenSource.Cancel();
cancelTokenSource.Dispose();
cancelTokenSource = new CancellationTokenSource();

_ = AddImagesToGrid(response.MoreDataAvailable, cancelTokenSource.Token);
}

protected void SearchQueryChanged()
private void SearchQueryChanged()
{
// Abort any in-progress search results from being rendered
ResetSearch();

selectionService.ClearSelection();
gridImages.Clear();
endOfImages = false;
Expand Down Expand Up @@ -289,16 +295,15 @@

foreach( var set in chunks )
{
// Another refresh, hot on our heels, is cancelling this one
if( token.IsCancellationRequested )
return;

StateHasChanged();

var toAdd = set.ExceptBy(gridImages.Select(x => x.ImageId), x => x).ToList();

var images = await imageCache.GetCachedImages(toAdd);

// Check if we had a cancellation request while we pulled back the images. If so, abort
if( token.IsCancellationRequested )
return;

if(images.Any())
{
gridImages.AddRange(images);
Expand Down
2 changes: 1 addition & 1 deletion Damselfly.Web.Client/wwwroot/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const CACHE_VERSION='4.2.1-20241230223619'
const CACHE_VERSION='4.2.1-20241231092916'

0 comments on commit bdea318

Please sign in to comment.