From 94eefb27b3908e5827a35d182f05fab6d0540ede Mon Sep 17 00:00:00 2001 From: Bagus Nur Listiyono Date: Wed, 7 Jan 2026 06:41:29 +0700 Subject: [PATCH 1/3] [UX] Put game file cleanup button to navigation bar As FileCleanupPage is not really a "page" rather an overlay, we manually invoke the overlay the same way as the QS invokes them and force the NavigationViewControl to select the last item/page back so the UI literally says "nothing happened here" i havent slept all night because my dumbass brain so help me --- .../XAMLs/MainApp/MainPage.Navigation.cs | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/CollapseLauncher/XAMLs/MainApp/MainPage.Navigation.cs b/CollapseLauncher/XAMLs/MainApp/MainPage.Navigation.cs index 09356a04c..c9fdd689e 100644 --- a/CollapseLauncher/XAMLs/MainApp/MainPage.Navigation.cs +++ b/CollapseLauncher/XAMLs/MainApp/MainPage.Navigation.cs @@ -1,4 +1,5 @@ using CollapseLauncher.Extension; +using CollapseLauncher.Helper.Loading; using CollapseLauncher.Helper.Metadata; using CollapseLauncher.Interfaces; using CollapseLauncher.Pages; @@ -15,6 +16,7 @@ using System.Threading.Tasks; using static CollapseLauncher.InnerLauncherConfig; using static CollapseLauncher.Statics.GamePropertyVault; +using static Hi3Helper.Locale; using static Hi3Helper.Logger; using static Hi3Helper.Shared.Region.LauncherConfig; @@ -51,6 +53,7 @@ void Impl() FontIcon IconCaches = new FontIcon { Glyph = m_isWindows11 ? "" : "" }; FontIcon IconGameSettings = new FontIcon { Glyph = "" }; FontIcon IconAppSettings = new FontIcon { Glyph = "" }; + FontIcon IconFilesCleanup = new FontIcon { Glyph = "" }; if (m_appMode == AppMode.Hi3CacheUpdater) { @@ -109,6 +112,10 @@ void Impl() break; } + NavigationViewControl.FooterMenuItems.Add(new NavigationViewItem + { Icon = IconFilesCleanup, Tag = "filescleanup"} + .BindNavigationViewItemText("_FileCleanupPage", "Title")); + if (NavigationViewControl.SettingsItem is NavigationViewItem SettingsItem) { SettingsItem.Icon = IconAppSettings; @@ -246,7 +253,7 @@ private void NavView_ItemInvoked(NavigationView sender, NavigationViewItemInvoke NavigateInnerSwitch(itemTag); } - private void NavigateInnerSwitch(string itemTag) + private async void NavigateInnerSwitch(string itemTag) { if (itemTag == PreviousTag) return; switch (itemTag) @@ -255,6 +262,20 @@ private void NavigateInnerSwitch(string itemTag) Navigate(typeof(HomePage), itemTag); break; + case "filescleanup": + LoadingMessageHelper.ShowLoadingFrame(); + // Initialize and get game state, then get the latest package info + LoadingMessageHelper.SetMessage(Lang._FileCleanupPage.LoadingTitle, + Lang._FileCleanupPage.LoadingSubtitle2); + + if (CurrentGameProperty?.GameInstall != null) + await CurrentGameProperty.GameInstall.CleanUpGameFiles(); + + // Manually reselect last item in toolbar as CleanUp is an overlay + NavigationViewControl.SelectedItem = NavigationViewControl.MenuItems.OfType() + .FirstOrDefault(x => x.Tag is string tag && tag == PreviousTag); ; + break; + case "repair": if (!(GetCurrentGameProperty().GameVersion?.GamePreset.IsRepairEnabled ?? false)) Navigate(typeof(UnavailablePage), itemTag); From 463131dea0ecbf2879fec94dc6a8edeaa6a2eaa9 Mon Sep 17 00:00:00 2001 From: Bagus Nur Listiyono Date: Wed, 7 Jan 2026 07:03:57 +0700 Subject: [PATCH 2/3] Add trycatch on filescleanup navigator --- .../XAMLs/MainApp/MainPage.Navigation.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/CollapseLauncher/XAMLs/MainApp/MainPage.Navigation.cs b/CollapseLauncher/XAMLs/MainApp/MainPage.Navigation.cs index c9fdd689e..51773e913 100644 --- a/CollapseLauncher/XAMLs/MainApp/MainPage.Navigation.cs +++ b/CollapseLauncher/XAMLs/MainApp/MainPage.Navigation.cs @@ -5,6 +5,7 @@ using CollapseLauncher.Pages; using CommunityToolkit.WinUI; using Hi3Helper; +using Hi3Helper.SentryHelper; using Microsoft.UI; using Microsoft.UI.Input; using Microsoft.UI.Xaml; @@ -268,12 +269,23 @@ private async void NavigateInnerSwitch(string itemTag) LoadingMessageHelper.SetMessage(Lang._FileCleanupPage.LoadingTitle, Lang._FileCleanupPage.LoadingSubtitle2); - if (CurrentGameProperty?.GameInstall != null) - await CurrentGameProperty.GameInstall.CleanUpGameFiles(); + try + { + if (CurrentGameProperty?.GameInstall != null) + await CurrentGameProperty.GameInstall.CleanUpGameFiles(); + } + catch (Exception ex) + { + LoadingMessageHelper.HideLoadingFrame(); + LogWriteLine($"[NavigateInnerSwitch(filescleanup] Error while calling the CleanUpGameFiles method! \r\n {ex}", LogType.Error, true); + await SentryHelper.ExceptionHandlerAsync(ex); + + ErrorSender.SendException(ex); + } // Manually reselect last item in toolbar as CleanUp is an overlay NavigationViewControl.SelectedItem = NavigationViewControl.MenuItems.OfType() - .FirstOrDefault(x => x.Tag is string tag && tag == PreviousTag); ; + .FirstOrDefault(x => x.Tag is string tag && tag == PreviousTag); break; case "repair": From 6c34fe991582b242b8a9bf3579a356b4d7a50e95 Mon Sep 17 00:00:00 2001 From: Bagus Nur Listiyono Date: Wed, 7 Jan 2026 07:41:53 +0700 Subject: [PATCH 3/3] Avoid sending error to Sentry twice note to self: SendException already send the exception data to Sentry yes, i'm the one who made it do that in the first place --- CollapseLauncher/XAMLs/MainApp/MainPage.Navigation.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CollapseLauncher/XAMLs/MainApp/MainPage.Navigation.cs b/CollapseLauncher/XAMLs/MainApp/MainPage.Navigation.cs index 51773e913..183a0a63c 100644 --- a/CollapseLauncher/XAMLs/MainApp/MainPage.Navigation.cs +++ b/CollapseLauncher/XAMLs/MainApp/MainPage.Navigation.cs @@ -277,8 +277,7 @@ private async void NavigateInnerSwitch(string itemTag) catch (Exception ex) { LoadingMessageHelper.HideLoadingFrame(); - LogWriteLine($"[NavigateInnerSwitch(filescleanup] Error while calling the CleanUpGameFiles method! \r\n {ex}", LogType.Error, true); - await SentryHelper.ExceptionHandlerAsync(ex); + LogWriteLine($"[NavigateInnerSwitch(filescleanup] Error while calling the CleanUpGameFiles method!\r\n{ex}", LogType.Error, true); ErrorSender.SendException(ex); }