Skip to content

Commit

Permalink
Keep UpdatePanel open when updating & fix refresh error after first u…
Browse files Browse the repository at this point in the history
…serlog update
  • Loading branch information
TremblingMoeNew committed May 27, 2023
1 parent aa9f7cb commit ddf1de7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
4 changes: 4 additions & 0 deletions DodocoTales.StarRail/Common/Signals/DDCS_Lib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 8 additions & 7 deletions DodocoTales.StarRail/Gui/ViewModels/DDCVMainWindowVM.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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)");

}
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)");

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}


Expand Down
2 changes: 1 addition & 1 deletion DodocoTales.StarRail/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
pu:ButtonHelper.ButtonStyle="Link"
FontSize="16" Click="UpdatePanelButton_Click" MouseRightButtonUp="UpdatePanelButton_Click" Content="{Binding CurrentUID, Converter={StaticResource UIDAnonyCon}}"/>
</Grid>
<Popup x:Name="UpdatePanel" StaysOpen="False" PopupAnimation="Fade" PlacementTarget="{Binding ElementName=BottomMenu}" Placement="Top" AllowsTransparency="True" >
<Popup x:Name="UpdatePanel" PopupAnimation="Fade" PlacementTarget="{Binding ElementName=BottomMenu}" Placement="Top" AllowsTransparency="True" StaysOpen="{Binding IsInUpdate}">
<Grid>
<Border Width="220" BorderBrush="#888888" BorderThickness="1" Margin="5">
<Border.Effect>
Expand Down
7 changes: 6 additions & 1 deletion DodocoTales.StarRail/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit ddf1de7

Please sign in to comment.