mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 15:43:22 +08:00
Refactor to use API state instead of logged in user state
This commit is contained in:
parent
826c82de47
commit
fe15b26bd2
@ -47,7 +47,7 @@ namespace osu.Game.Overlays
|
|||||||
private IUser? user;
|
private IUser? user;
|
||||||
private IRulesetInfo? ruleset;
|
private IRulesetInfo? ruleset;
|
||||||
|
|
||||||
private IBindable<APIUser> apiUser = null!;
|
private readonly IBindable<APIState> apiState = new Bindable<APIState>();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private RulesetStore rulesets { get; set; } = null!;
|
private RulesetStore rulesets { get; set; } = null!;
|
||||||
@ -68,10 +68,10 @@ namespace osu.Game.Overlays
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
apiUser = API.LocalUser.GetBoundCopy();
|
apiState.BindTo(API.State);
|
||||||
apiUser.BindValueChanged(_ => Schedule(() =>
|
apiState.BindValueChanged(state => Schedule(() =>
|
||||||
{
|
{
|
||||||
if (API.IsLoggedIn)
|
if (state.NewValue == APIState.Online && user != null)
|
||||||
fetchAndSetContent();
|
fetchAndSetContent();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -89,7 +89,6 @@ namespace osu.Game.Overlays
|
|||||||
ruleset = userRuleset;
|
ruleset = userRuleset;
|
||||||
|
|
||||||
Show();
|
Show();
|
||||||
|
|
||||||
fetchAndSetContent();
|
fetchAndSetContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,13 +170,14 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
sectionsContainer.ScrollToTop();
|
sectionsContainer.ScrollToTop();
|
||||||
|
|
||||||
if (API.State.Value != APIState.Online)
|
if (API.State.Value != APIState.Offline)
|
||||||
return;
|
{
|
||||||
|
userReq = user.OnlineID > 1 ? new GetUserRequest(user.OnlineID, ruleset) : new GetUserRequest(user.Username, ruleset);
|
||||||
|
userReq.Success += u => userLoadComplete(u, ruleset);
|
||||||
|
|
||||||
userReq = user.OnlineID > 1 ? new GetUserRequest(user.OnlineID, ruleset) : new GetUserRequest(user.Username, ruleset);
|
API.Queue(userReq);
|
||||||
userReq.Success += u => userLoadComplete(u, ruleset);
|
loadingLayer.Show();
|
||||||
API.Queue(userReq);
|
}
|
||||||
loadingLayer.Show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void userLoadComplete(APIUser loadedUser, IRulesetInfo? userRuleset)
|
private void userLoadComplete(APIUser loadedUser, IRulesetInfo? userRuleset)
|
||||||
|
Loading…
Reference in New Issue
Block a user