diff --git a/ElectronicObserver/Window/Wpf/SenkaLeaderboard/SenkaLeaderboardManager.cs b/ElectronicObserver/Window/Wpf/SenkaLeaderboard/SenkaLeaderboardManager.cs index f23b1ea38..b59b5b764 100644 --- a/ElectronicObserver/Window/Wpf/SenkaLeaderboard/SenkaLeaderboardManager.cs +++ b/ElectronicObserver/Window/Wpf/SenkaLeaderboard/SenkaLeaderboardManager.cs @@ -22,7 +22,7 @@ public partial class SenkaLeaderboardManager : ObservableObject [ObservableProperty] private partial SenkaLeaderboardRefreshKind CurrentSenkaLeaderboardRefreshKind { get; set; } - + public SenkaLeaderboardManager(TimeChangeService timeChangeService, Tracker tracker) { APIObserver.Instance.ApiReqRanking_Mxltvkpyuklh.ResponseReceived += HandleData; @@ -74,6 +74,15 @@ private void HandleData(dynamic data) { CurrentCutoffData.HandleEntry(entry); } + + // Due to how we parse data to guess a key, we have to run the decoding twice for the first "batch" for data to be accurate + if (CurrentCutoffData.LoadedEntriesCount is 10) + { + foreach (ApiList entry in parsedData.ApiList) + { + CurrentCutoffData.HandleEntry(entry); + } + } } catch (Exception ex) { diff --git a/ElectronicObserver/Window/Wpf/SenkaLeaderboard/SenkaLeaderboardViewModel.cs b/ElectronicObserver/Window/Wpf/SenkaLeaderboard/SenkaLeaderboardViewModel.cs index 586cd8f9a..498e6be56 100644 --- a/ElectronicObserver/Window/Wpf/SenkaLeaderboard/SenkaLeaderboardViewModel.cs +++ b/ElectronicObserver/Window/Wpf/SenkaLeaderboard/SenkaLeaderboardViewModel.cs @@ -24,8 +24,6 @@ public partial class SenkaLeaderboardViewModel : AnchorableViewModel [ObservableProperty] private partial List SenkaData { get; set; } - private Dictionary SenkaRawData { get; set; } = []; - public PagingControlViewModel PagingViewModel { get; } public DataGridViewModel DataGridViewModel { get; } @@ -66,7 +64,6 @@ public void Update() public void Reset() { SenkaData = NewLeaderboard(); - SenkaRawData = []; Update(); UpdateEntryCount(); } @@ -100,15 +97,8 @@ public void HandleEntry(ApiList entry) SenkaData[entry.ApiMxltvkpyuklh - 1] = parsedEntry; - SenkaRawData.Add(entry.ApiMxltvkpyuklh, entry); - UpdateEntryCount(); - if (LoadedEntriesCount % 10 is 0) - { - RunAnotherRoundOfDecoding(); - } - PagingViewModel.DisplayPageFromElementKey(entry.ApiMxltvkpyuklh - 1); } @@ -154,18 +144,6 @@ public void HandleEntry(ApiList entry) }; } - private void RunAnotherRoundOfDecoding() - { - foreach (SenkaEntryModel entry in SenkaData.Where(entry => entry.IsKnown).OrderByDescending(entry => entry.Position)) - { - if (SenkaRawData.TryGetValue(entry.Position, out ApiList? rawData) && ConvertApiToSenkaModel(rawData) is SenkaEntryModel parsedEntry) - { - entry.MedalCount = parsedEntry.MedalCount; - entry.Points = parsedEntry.Points; - } - } - } - private void UpdateEntryCount() { LoadedEntriesCount = SenkaData.Count(entry => entry.IsKnown);