From 041ec59914cddb3e3d395d41e920f62abe20dc5c Mon Sep 17 00:00:00 2001 From: JT Date: Sat, 13 Apr 2024 23:48:34 -0700 Subject: [PATCH] if the user never closes the package install dialog / is still on the same page when the install is finished, go back to the packages page --- StabilityMatrix.Avalonia/Services/INavigationService.cs | 1 + StabilityMatrix.Avalonia/Services/NavigationService.cs | 3 +++ .../PackageManager/PackageInstallDetailViewModel.cs | 7 +++++++ 3 files changed, 11 insertions(+) diff --git a/StabilityMatrix.Avalonia/Services/INavigationService.cs b/StabilityMatrix.Avalonia/Services/INavigationService.cs index 68f7f261..690966da 100644 --- a/StabilityMatrix.Avalonia/Services/INavigationService.cs +++ b/StabilityMatrix.Avalonia/Services/INavigationService.cs @@ -39,4 +39,5 @@ public interface INavigationService<[SuppressMessage("ReSharper", "UnusedTypePar bool GoBack(); bool CanGoBack { get; } + object? CurrentPageDataContext { get; } } diff --git a/StabilityMatrix.Avalonia/Services/NavigationService.cs b/StabilityMatrix.Avalonia/Services/NavigationService.cs index 8778f7ca..9e6ac801 100644 --- a/StabilityMatrix.Avalonia/Services/NavigationService.cs +++ b/StabilityMatrix.Avalonia/Services/NavigationService.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using Avalonia.Controls; using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Media.Animation; using FluentAvalonia.UI.Navigation; @@ -190,4 +191,6 @@ public class NavigationService : INavigationService } public bool CanGoBack => _frame?.CanGoBack ?? false; + + public object? CurrentPageDataContext => (_frame?.Content as Control)?.DataContext; } diff --git a/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallDetailViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallDetailViewModel.cs index 6c24efc2..5766a8a8 100644 --- a/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallDetailViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallDetailViewModel.cs @@ -283,6 +283,13 @@ public partial class PackageInstallDetailViewModel( if (!runner.Failed) { + if (ReferenceEquals(this, packageNavigationService.CurrentPageDataContext)) + { + packageNavigationService.GoBack(); + packageNavigationService.GoBack(); + await Task.Delay(100); + } + EventManager.Instance.OnInstalledPackagesChanged(); } }