mirror of
https://github.com/osukey/osukey.git
synced 2025-05-11 08:37:34 +09:00
Fix various failures in initial statistics fetch
- If the local user is restricted, then attempting to fetch their data from the `/users` endpoint would result in an empty response. - Even if the user was successfully fetched, their `RulesetsStatistics` may not be populated (and instead be `null`). Curiously this was not picked up by static analysis until the first issue was fixed. Closes #21839.
This commit is contained in:
parent
5e8ca11ded
commit
e9d32fca18
@ -75,15 +75,27 @@ namespace osu.Game.Online.Solo
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var userRequest = new GetUsersRequest(new[] { localUser.OnlineID });
|
var userRequest = new GetUsersRequest(new[] { localUser.OnlineID });
|
||||||
userRequest.Success += response => Schedule(() =>
|
userRequest.Success += initialiseUserStatistics;
|
||||||
{
|
|
||||||
latestStatistics = new Dictionary<string, UserStatistics>();
|
|
||||||
foreach (var rulesetStats in response.Users.Single().RulesetsStatistics)
|
|
||||||
latestStatistics.Add(rulesetStats.Key, rulesetStats.Value);
|
|
||||||
});
|
|
||||||
api.Queue(userRequest);
|
api.Queue(userRequest);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
private void initialiseUserStatistics(GetUsersResponse response) => Schedule(() =>
|
||||||
|
{
|
||||||
|
var user = response.Users.SingleOrDefault();
|
||||||
|
|
||||||
|
// possible if the user is restricted or similar.
|
||||||
|
if (user == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
latestStatistics = new Dictionary<string, UserStatistics>();
|
||||||
|
|
||||||
|
if (user.RulesetsStatistics != null)
|
||||||
|
{
|
||||||
|
foreach (var rulesetStats in user.RulesetsStatistics)
|
||||||
|
latestStatistics.Add(rulesetStats.Key, rulesetStats.Value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
private void userScoreProcessed(int userId, long scoreId)
|
private void userScoreProcessed(int userId, long scoreId)
|
||||||
{
|
{
|
||||||
if (userId != api.LocalUser.Value?.OnlineID)
|
if (userId != api.LocalUser.Value?.OnlineID)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user