mirror of https://github.com/ppy/osu
Fix `PopulateUser` not populating immediately when `immediate` is specified (due to scheduling)
This commit is contained in:
parent
3130616300
commit
35168948fe
|
@ -226,8 +226,30 @@ public void PopulateUser(User user, Action success = null, Action failure = null
|
|||
{
|
||||
var req = new GetUserRequest(user.Id, Ruleset.Value);
|
||||
|
||||
req.Success += res =>
|
||||
if (immediate)
|
||||
{
|
||||
API.Perform(req);
|
||||
populate();
|
||||
}
|
||||
else
|
||||
{
|
||||
req.Success += res => { populate(); };
|
||||
req.Failure += _ =>
|
||||
{
|
||||
user.Id = 1;
|
||||
failure?.Invoke();
|
||||
};
|
||||
|
||||
API.Queue(req);
|
||||
}
|
||||
|
||||
void populate()
|
||||
{
|
||||
var res = req.Response;
|
||||
|
||||
if (res == null)
|
||||
return;
|
||||
|
||||
user.Id = res.Id;
|
||||
|
||||
user.Username = res.Username;
|
||||
|
@ -236,18 +258,7 @@ public void PopulateUser(User user, Action success = null, Action failure = null
|
|||
user.Cover = res.Cover;
|
||||
|
||||
success?.Invoke();
|
||||
};
|
||||
|
||||
req.Failure += _ =>
|
||||
{
|
||||
user.Id = 1;
|
||||
failure?.Invoke();
|
||||
};
|
||||
|
||||
if (immediate)
|
||||
API.Perform(req);
|
||||
else
|
||||
API.Queue(req);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
|
|
Loading…
Reference in New Issue