diff --git a/Hollow/App.axaml.cs b/Hollow/App.axaml.cs index b83a4fe..cf3aa10 100644 --- a/Hollow/App.axaml.cs +++ b/Hollow/App.axaml.cs @@ -36,6 +36,7 @@ public override void Initialize() AvaloniaXamlLoader.Load(this); _provider = ConfigureServices(); + //TODO: Platform specific Environment.SetEnvironmentVariable("WEBVIEW2_USER_DATA_FOLDER", AppInfo.CachesDir); AvaloniaWebViewBuilder.Initialize(default); } diff --git a/Hollow/Services/GachaService/GachaService.cs b/Hollow/Services/GachaService/GachaService.cs index 0be1949..5849314 100644 --- a/Hollow/Services/GachaService/GachaService.cs +++ b/Hollow/Services/GachaService/GachaService.cs @@ -12,6 +12,7 @@ using Hollow.Helpers; using Hollow.Models; using Hollow.Services.ConfigurationService; +using Serilog; namespace Hollow.Services.GachaService; @@ -181,8 +182,9 @@ public Response TryGetAuthKey() return authKey; } - var targetGachaLogUrl = authKey.Data; - return new Response (true) {Data = targetGachaLogUrl.Split("&authkey=")[1].Split("&")[0]}; + var targetGachaLogUrl = authKey.Data.Split("&authkey=")[1].Split("&")[0]; + Log.Information("Get authKey: {0}", targetGachaLogUrl); + return new Response (true) {Data = targetGachaLogUrl}; } private Response GetAuthKeyFromFile(string dataPath) diff --git a/Hollow/ViewModels/Pages/SignalSearchViewModel.cs b/Hollow/ViewModels/Pages/SignalSearchViewModel.cs index daa69f3..af845ca 100644 --- a/Hollow/ViewModels/Pages/SignalSearchViewModel.cs +++ b/Hollow/ViewModels/Pages/SignalSearchViewModel.cs @@ -42,7 +42,7 @@ public void Navigated() [ObservableProperty] private bool _controlEnabled = true; [ObservableProperty] private ObservableCollection _uidList = []; - [ObservableProperty] private string _selectedUid = ""; + [ObservableProperty] private string? _selectedUid; private Dictionary? _gachaRecords; private Dictionary? _analyzedGachaRecords; @@ -74,7 +74,7 @@ private void RemoveCoverage() ControlEnabled = true; } - private async Task LoadGachaRecords() + private async Task LoadGachaRecords(string? updatedUid = null) { IntoCoverage(); @@ -88,7 +88,6 @@ private async Task LoadGachaRecords() ControlEnabled = true; return; } - await Task.Delay(100); // Analyze GetGachaLogShortMessage = Lang.SignalSearch_LoadGachaRecords_Analyze; @@ -97,8 +96,8 @@ private async Task LoadGachaRecords() item => GachaAnalyser.FromGachaRecords(item.Value)); UidList = new ObservableCollection(_gachaRecords!.Keys); - SelectedUid = UidList[0]; - SelectedAnalyzedGachaRecords = _analyzedGachaRecords[UidList[0]]; + SelectedUid = UidList.FirstOrDefault(uid => uid == updatedUid) ?? UidList.First(); + SelectedAnalyzedGachaRecords = _analyzedGachaRecords[SelectedUid]; await Task.Delay(100); RemoveCoverage(); @@ -107,7 +106,10 @@ private async Task LoadGachaRecords() [RelayCommand] private void ChangeUid() { - SelectedAnalyzedGachaRecords = _analyzedGachaRecords![SelectedUid]; + if (SelectedUid != null && _analyzedGachaRecords!.TryGetValue(SelectedUid, out var value)) + { + SelectedAnalyzedGachaRecords = value; + } } [RelayCommand] @@ -148,7 +150,7 @@ private async Task UpdateByWebCaches() var gachaRecord = await _gachaService.TryGetGachaLogs(authKey.Data, gachaProgress); await File.WriteAllTextAsync(Path.Combine(AppInfo.GachaRecordsDir, $"{gachaRecord.Data.Info.Uid}.json"), JsonSerializer.Serialize(gachaRecord.Data, new JsonSerializerOptions { WriteIndented = true, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping })); - await LoadGachaRecords(); + await LoadGachaRecords(gachaRecord.Data.Info.Uid); RemoveCoverage(); } } \ No newline at end of file diff --git a/Hollow/Views/Pages/SignalSearch.axaml b/Hollow/Views/Pages/SignalSearch.axaml index ffe5cd5..c899038 100644 --- a/Hollow/Views/Pages/SignalSearch.axaml +++ b/Hollow/Views/Pages/SignalSearch.axaml @@ -28,7 +28,7 @@ Spacing="15" VerticalAlignment="Center">