Skip to content

Commit

Permalink
Improve logic when adding files to the iterated list.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Oct 24, 2024
1 parent 61a16a1 commit 423faef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/PicView.Avalonia/Navigation/ImageIterator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ private async Task OnFileAdded(FileSystemEventArgs e)
}

ImagePaths = newList;

SetTitleHelper.RefreshTitle(_vm);

IsRunning = false;

Expand All @@ -150,12 +152,10 @@ private async Task OnFileAdded(FileSystemEventArgs e)
if (PreLoader.Contains(index, ImagePaths) || PreLoader.Contains(nextIndex, ImagePaths) ||
PreLoader.Contains(prevIndex, ImagePaths))
{
PreLoader.Clear();
PreLoader.RefreshAllFileInfo(ImagePaths);
cleared = true;
}

SetTitleHelper.SetTitle(_vm);

var isGalleryItemAdded = await GalleryFunctions.AddGalleryItem(index, fileInfo, _vm);
if (isGalleryItemAdded)
{
Expand Down
10 changes: 10 additions & 0 deletions src/PicView.Avalonia/Navigation/Preloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ public async Task<bool> RefreshFileInfo(int index, List<string> list)

return removed;
}

public void RefreshAllFileInfo(List<string> list)
{
foreach (var item in _preLoadList)
{
if (item.Value is null) continue;
var fileInfo = new FileInfo(list[item.Key]);
item.Value.ImageModel.FileInfo = fileInfo;
}
}

/// <summary>
/// Removes all keys from the cache.
Expand Down

0 comments on commit 423faef

Please sign in to comment.