Fix crash caused by user json order changing

This commit is contained in:
Dean Herbert 2020-04-02 18:46:09 +09:00
parent 7c428011a2
commit c18248c827
1 changed files with 20 additions and 7 deletions

View File

@ -173,8 +173,27 @@ public class KudosuCount
public int Available;
}
private UserStatistics statistics;
[JsonProperty(@"statistics")]
public UserStatistics Statistics;
public UserStatistics Statistics
{
get => statistics ??= new UserStatistics();
set
{
if (statistics != null)
// we may already have rank history populated
value.RankHistory = statistics.RankHistory;
statistics = value;
}
}
[JsonProperty(@"rankHistory")]
private RankHistoryData rankHistory
{
set => statistics.RankHistory = value;
}
public class RankHistoryData
{
@ -185,12 +204,6 @@ public class RankHistoryData
public int[] Data;
}
[JsonProperty(@"rankHistory")]
private RankHistoryData rankHistory
{
set => Statistics.RankHistory = value;
}
[JsonProperty("badges")]
public Badge[] Badges;