From ddf1de713c4a88d0ae054220d95370358ee27fc4 Mon Sep 17 00:00:00 2001 From: TremblingMoeNew Date: Sat, 27 May 2023 14:37:18 +0800 Subject: [PATCH] Keep UpdatePanel open when updating & fix refresh error after first userlog update --- DodocoTales.StarRail/Common/Signals/DDCS_Lib.cs | 4 ++++ .../Gui/ViewModels/DDCVMainWindowVM.cs | 15 ++++++++------- .../Gui/ViewModels/Dialogs/DDCVImportDialogVM.cs | 2 +- DodocoTales.StarRail/MainWindow.xaml | 2 +- DodocoTales.StarRail/MainWindow.xaml.cs | 7 ++++++- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/DodocoTales.StarRail/Common/Signals/DDCS_Lib.cs b/DodocoTales.StarRail/Common/Signals/DDCS_Lib.cs index 1626fbb..a961acb 100644 --- a/DodocoTales.StarRail/Common/Signals/DDCS_Lib.cs +++ b/DodocoTales.StarRail/Common/Signals/DDCS_Lib.cs @@ -42,6 +42,10 @@ public static void Emit_CurUserSwapReverted() public static void Emit_CurUserSwapCompleted(long uid) => ExecUidParamDelegate(CurUserSwapCompleted, uid); + public static DDCSCommonDelegate CurUserUpdateCompleted; + public static void Emit_CurUserUpdateCompleted() + => ExecCommonDelegate(CurUserUpdateCompleted); + public static DDCSUidParamDelegate UserLibUidDeplicated; public static void Emit_UserLibUidDeplicated(long uid) => ExecUidParamDelegate(UserLibUidDeplicated, uid); diff --git a/DodocoTales.StarRail/Gui/ViewModels/DDCVMainWindowVM.cs b/DodocoTales.StarRail/Gui/ViewModels/DDCVMainWindowVM.cs index 34ac0a4..7cf85b7 100644 --- a/DodocoTales.StarRail/Gui/ViewModels/DDCVMainWindowVM.cs +++ b/DodocoTales.StarRail/Gui/ViewModels/DDCVMainWindowVM.cs @@ -1,4 +1,5 @@ using CommunityToolkit.Mvvm.ComponentModel; +using DodocoTales.SR.Common; using DodocoTales.SR.Gui.Models; using DodocoTales.SR.Gui.Views.Windows; using DodocoTales.SR.Library; @@ -216,8 +217,8 @@ public async Task WishLogUpdateAppendedFromCache() await DDCG.WebLogLoader.GetGachaLogsAsNormalMode(authkey, client.ClientType); IsInUpdate = false; - DDCV.RefreshAll(); Notice.Show("跃迁记录常规更新完毕", "跃迁记录更新完毕", MessageBoxIcon.Success); + DDCS.Emit_CurUserUpdateCompleted(); //DDCLog.Info(DCLN.Gui, "Wish log update completed. (Append mode, Cache mode)"); } @@ -257,10 +258,10 @@ public async Task WishLogUpdateFullFromCache() await DDCG.WebLogLoader.GetGachaLogsAsFullMode(authkey, client.ClientType); IsInUpdate = false; - DDCV.RefreshAll(); Notice.Show("跃迁记录全量更新完毕", "跃迁记录更新完毕", MessageBoxIcon.Success); + DDCS.Emit_CurUserUpdateCompleted(); //DDCLog.Info(DCLN.Gui, "Wish log update completed. (Full mode, Cache mode)"); - + } public async Task WishLogUpdateAppendedFromProxy() @@ -294,10 +295,10 @@ public async Task WishLogUpdateAppendedFromProxy() DDCL.CurrentUser.SwapUser(user); await DDCG.WebLogLoader.GetGachaLogsAsNormalMode(authkey, clientType); IsInUpdate = false; - DDCV.RefreshAll(); Notice.Show("跃迁记录常规更新完毕", "跃迁记录更新完毕", MessageBoxIcon.Success); + DDCS.Emit_CurUserUpdateCompleted(); //DDCLog.Info(DCLN.Gui, "Wish log update completed. (Append mode, Proxy mode)"); - + } public async Task WishLogUpdateFullFromProxy() @@ -330,10 +331,10 @@ public async Task WishLogUpdateFullFromProxy() DDCL.CurrentUser.SwapUser(user); await DDCG.WebLogLoader.GetGachaLogsAsFullMode(authkey, clientType); IsInUpdate = false; - DDCV.RefreshAll(); Notice.Show("跃迁记录全量更新完毕", "跃迁记录更新完毕", MessageBoxIcon.Success); + DDCS.Emit_CurUserUpdateCompleted(); //DDCLog.Info(DCLN.Gui, "Wish log update completed. (Full mode, Proxy mode)"); - + } } diff --git a/DodocoTales.StarRail/Gui/ViewModels/Dialogs/DDCVImportDialogVM.cs b/DodocoTales.StarRail/Gui/ViewModels/Dialogs/DDCVImportDialogVM.cs index a08099c..97bc8f1 100644 --- a/DodocoTales.StarRail/Gui/ViewModels/Dialogs/DDCVImportDialogVM.cs +++ b/DodocoTales.StarRail/Gui/ViewModels/Dialogs/DDCVImportDialogVM.cs @@ -243,7 +243,7 @@ public void Import() var added_cnt = DDCG.UFImporter.Import(SelectedUID, list, SelectedClientType, TimeZone); Notice.Show($"跃迁记录导入完毕。\n{available_cnt}个记录项读取成功,{failed_cnt}个记录项读取失败。\n用户{SelectedUID}新增{added_cnt}个跃迁记录项。", "跃迁记录导入", Panuon.UI.Silver.MessageBoxIcon.Success); DDCL.CurrentUser.SwapUser(SelectedUID); - DDCV.RefreshAll(); + DDCS.Emit_CurUserUpdateCompleted(); } diff --git a/DodocoTales.StarRail/MainWindow.xaml b/DodocoTales.StarRail/MainWindow.xaml index 1e99796..3a5df8c 100644 --- a/DodocoTales.StarRail/MainWindow.xaml +++ b/DodocoTales.StarRail/MainWindow.xaml @@ -76,7 +76,7 @@ pu:ButtonHelper.ButtonStyle="Link" FontSize="16" Click="UpdatePanelButton_Click" MouseRightButtonUp="UpdatePanelButton_Click" Content="{Binding CurrentUID, Converter={StaticResource UIDAnonyCon}}"/> - + diff --git a/DodocoTales.StarRail/MainWindow.xaml.cs b/DodocoTales.StarRail/MainWindow.xaml.cs index fb8075c..b82cb21 100644 --- a/DodocoTales.StarRail/MainWindow.xaml.cs +++ b/DodocoTales.StarRail/MainWindow.xaml.cs @@ -39,6 +39,7 @@ public MainWindow() DDCV.MainNavigater = MainNavigator; DDCV.RegisterMainScreens(); DDCS.CurUserSwapCompleted += OnUIDSwapCompleted; + DDCS.CurUserUpdateCompleted += OnCurrentUserUpdateCompleted; DDCS.ProxyCaptured += OnProxyCaptured; DDCS.ClientNeedsUpdate += OnClientUpdateDownloadStart; DDCS.ClientUpdateDownloadCompleted += OnClientUpdateDownloadCompleted; @@ -114,7 +115,11 @@ private void UpdatePanelButton_Click(object sender, RoutedEventArgs e) private void OnUIDSwapCompleted(long uid) { VM.RefreshCurrentUID(); - if (!VM.IsInUpdate) DDCV.RefreshAll(); + } + + private void OnCurrentUserUpdateCompleted() + { + VM.RefreshCurrentUID(); } private async void OnProxyCaptured()