Skip to content

Commit

Permalink
Make Toggle galleries void instead of task
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Feb 2, 2025
1 parent 6171761 commit bf65aa0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
18 changes: 8 additions & 10 deletions src/PicView.Avalonia/Gallery/GalleryFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ await Dispatcher.UIThread.InvokeAsync(() =>
{
if (IsFullGalleryOpen)
{
await ToggleGallery(vm);
ToggleGallery(vm);
}

await NavigationHelper.Navigate(vm.ImageIterator.ImagePaths.IndexOf(fileInfo.FullName), vm).ConfigureAwait(false);
Expand Down Expand Up @@ -274,7 +274,7 @@ void Center()
public static bool IsFullGalleryOpen { get; private set; }
public static bool IsBottomGalleryOpen { get; private set; }

public static async Task ToggleGallery(MainViewModel vm)
public static void ToggleGallery(MainViewModel vm)
{
if (vm is null || !NavigationHelper.CanNavigate(vm))
{
Expand Down Expand Up @@ -319,11 +319,11 @@ public static async Task ToggleGallery(MainViewModel vm)
}
}


_ = Task.Run(() => GalleryLoad.LoadGallery(vm, Path.GetDirectoryName(vm.ImageIterator.ImagePaths[0])));
await SaveSettingsAsync();
}

public static async Task OpenCloseBottomGallery(MainViewModel vm)
public static void OpenCloseBottomGallery(MainViewModel vm)
{
if (vm is null)
{
Expand All @@ -339,7 +339,6 @@ public static async Task OpenCloseBottomGallery(MainViewModel vm)
Settings.Gallery.IsBottomGalleryShown = false;
IsFullGalleryOpen = false;
IsBottomGalleryOpen = false;
await SaveSettingsAsync();
return;
}

Expand All @@ -352,13 +351,12 @@ public static async Task OpenCloseBottomGallery(MainViewModel vm)
}

vm.GetIsShowingBottomGalleryTranslation = TranslationHelper.Translation.HideBottomGallery;
await SaveSettingsAsync();
if (!NavigationHelper.CanNavigate(vm))
{
return;
}

await Task.Run(() => GalleryLoad.LoadGallery(vm, Path.GetDirectoryName(vm.ImageIterator.ImagePaths[0])));
Task.Run(() => GalleryLoad.LoadGallery(vm, Path.GetDirectoryName(vm.ImageIterator.ImagePaths[0])));
}

public static void OpenBottomGallery(MainViewModel vm)
Expand All @@ -368,15 +366,15 @@ public static void OpenBottomGallery(MainViewModel vm)
vm.GalleryVerticalAlignment = VerticalAlignment.Bottom;
}

public static async Task CloseGallery(MainViewModel vm)
public static void CloseGallery(MainViewModel vm)
{
if (IsFullGalleryOpen)
{
await ToggleGallery(vm);
ToggleGallery(vm);
}
else
{
await OpenCloseBottomGallery(vm);
OpenCloseBottomGallery(vm);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/PicView.Avalonia/Gallery/GalleryLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ await Dispatcher.UIThread.InvokeAsync(() =>
{
if (GalleryFunctions.IsFullGalleryOpen)
{
await GalleryFunctions.ToggleGallery(vm);
GalleryFunctions.ToggleGallery(vm);
}
await NavigationHelper.Navigate(vm.ImageIterator.ImagePaths.IndexOf(fileInfos[i1].FullName), vm).ConfigureAwait(false);
};
Expand Down
2 changes: 1 addition & 1 deletion src/PicView.Avalonia/Gallery/GalleryNavigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public static async Task GalleryClick(MainViewModel? vm)
{
return;
}
await GalleryFunctions.ToggleGallery(vm);
GalleryFunctions.ToggleGallery(vm);
if (vm.SelectedGalleryItemIndex != vm.ImageIterator.CurrentIndex)
{
await NavigationHelper.Navigate(vm.SelectedGalleryItemIndex, vm).ConfigureAwait(false);
Expand Down
15 changes: 9 additions & 6 deletions src/PicView.Avalonia/UI/FunctionsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,19 +383,22 @@ public static async Task ToggleTaskbarProgress()

#region Gallery functions

public static async Task ToggleGallery()
public static Task ToggleGallery()
{
await GalleryFunctions.ToggleGallery(Vm).ConfigureAwait(false);
GalleryFunctions.ToggleGallery(Vm);
return Task.CompletedTask;
}

public static async Task OpenCloseBottomGallery()
public static Task OpenCloseBottomGallery()
{
await GalleryFunctions.OpenCloseBottomGallery(Vm).ConfigureAwait(false);
GalleryFunctions.OpenCloseBottomGallery(Vm);
return Task.CompletedTask;
}

public static async Task CloseGallery()
public static Task CloseGallery()
{
await GalleryFunctions.CloseGallery(Vm);
GalleryFunctions.CloseGallery(Vm);
return Task.CompletedTask;
}

public static async Task GalleryClick()
Expand Down

0 comments on commit bf65aa0

Please sign in to comment.