Skip to content

Commit

Permalink
Attempt to reload with subdirectories and reset the settings when loa…
Browse files Browse the repository at this point in the history
…ding a directory. Fix loading statements.
  • Loading branch information
Ruben2776 committed Oct 25, 2024
1 parent 458757e commit 0059ff8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/PicView.Avalonia/Navigation/ErrorHandling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void Start()
vm.GalleryMargin = new Thickness(0, 0, 0, 0);
vm.GetIndex = 0;
vm.PlatformService.StopTaskbarProgress();
vm.IsLoading = false;
}
}

Expand Down
1 change: 0 additions & 1 deletion src/PicView.Avalonia/Navigation/ImageIterator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,6 @@ void TryShowPreview(PreLoader.PreLoadValue preloadValue)
return;
}
SetTitleHelper.SetLoadingTitle(_vm);
_vm.IsLoading = true;
_vm.ImageSource = null;
_vm.SecondaryImageSource = null;
Expand Down
27 changes: 26 additions & 1 deletion src/PicView.Avalonia/Navigation/NavigationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -463,13 +463,38 @@ await Task.Run(async () =>
/// <returns>A task representing the asynchronous operation.</returns>
public static async Task LoadPicFromDirectoryAsync(string file, MainViewModel vm, FileInfo? fileInfo = null)
{
vm.IsLoading = true;
SetTitleHelper.SetLoadingTitle(vm);

if (SettingsHelper.Settings.UIProperties.IsTaskbarProgressEnabled)
{
vm.PlatformService.StopTaskbarProgress();
}

fileInfo ??= new FileInfo(file);
vm.ImageIterator?.Dispose();
vm.ImageIterator = new ImageIterator(fileInfo, vm);
var fileList = await Task.FromResult(vm.PlatformService.GetFiles(fileInfo)).ConfigureAwait(false);
if (fileList.Count <= 0)
{
// Attempt to reload with subdirectories and reset the setting
if (!SettingsHelper.Settings.Sorting.IncludeSubDirectories)
{
SettingsHelper.Settings.Sorting.IncludeSubDirectories = true;
fileList = await Task.FromResult(vm.PlatformService.GetFiles(fileInfo)).ConfigureAwait(false);
if (fileList.Count <= 0)
{
await ErrorHandling.ReloadAsync(vm).ConfigureAwait(false);
return;
}
SettingsHelper.Settings.Sorting.IncludeSubDirectories = false;
}
else
{
await ErrorHandling.ReloadAsync(vm).ConfigureAwait(false);
return;
}
}
vm.ImageIterator = new ImageIterator(fileInfo, fileList, 0, vm);
await vm.ImageIterator.IterateToIndex(0);
await CheckAndReloadGallery(fileInfo, vm);
}
Expand Down

0 comments on commit 0059ff8

Please sign in to comment.