Skip to content

Commit

Permalink
Refactor adding to preloader
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Sep 20, 2024
1 parent b4c04a7 commit e073e92
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/PicView.Avalonia/Navigation/Preloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,29 @@ public async Task<bool> AddAsync(int index, List<string> list, ImageModel? image
var add = _preLoadList.TryAdd(index, preLoadValue);
if (add)
{
imageModel ??= new ImageModel();
imageModel.FileInfo ??= new FileInfo(list[index]);
preLoadValue.ImageModel = imageModel;
if (imageModel.Image is null)
if (imageModel is null)
{
preLoadValue.IsLoading = true;

preLoadValue.ImageModel = await ImageHelper.GetImageModelAsync(imageModel.FileInfo).ConfigureAwait(false);
var fileInfo = new FileInfo(list[index]);
imageModel = await ImageHelper.GetImageModelAsync(fileInfo).ConfigureAwait(false);
preLoadValue.ImageModel = imageModel;
}

if (imageModel.EXIFOrientation is null || imageModel is { EXIFOrientation: EXIFHelper.EXIFOrientation.None, Image: not null })
else
{
preLoadValue.ImageModel.EXIFOrientation = EXIFHelper.GetImageOrientation(imageModel.FileInfo);
preLoadValue.ImageModel = imageModel;
if (imageModel.Image is null)
{
preLoadValue.IsLoading = true;

preLoadValue.ImageModel = await ImageHelper.GetImageModelAsync(imageModel.FileInfo).ConfigureAwait(false);
}
}
else

if (imageModel.EXIFOrientation is null)
{
preLoadValue.ImageModel.EXIFOrientation = EXIFHelper.EXIFOrientation.None;
preLoadValue.ImageModel.EXIFOrientation = EXIFHelper.GetImageOrientation(imageModel.FileInfo);
}

#if DEBUG
if (ShowAddRemove)
Trace.WriteLine($"{imageModel?.FileInfo?.Name} added at {index}");
Expand Down

0 comments on commit e073e92

Please sign in to comment.