mirror of
https://github.com/osukey/osukey.git
synced 2025-08-02 06:07:11 +09:00
Make IAPIProvider read-only bindables into IBindables
This commit is contained in:
@ -39,11 +39,15 @@ namespace osu.Game.Online.API
|
||||
|
||||
private string password;
|
||||
|
||||
public Bindable<User> LocalUser { get; } = new Bindable<User>(createGuestUser());
|
||||
public IBindable<User> LocalUser => localUser;
|
||||
public IBindableList<User> Friends => friends;
|
||||
public IBindable<UserActivity> Activity => activity;
|
||||
|
||||
public BindableList<User> Friends { get; } = new BindableList<User>();
|
||||
private Bindable<User> localUser { get; } = new Bindable<User>(createGuestUser());
|
||||
|
||||
public Bindable<UserActivity> Activity { get; } = new Bindable<UserActivity>();
|
||||
private BindableList<User> friends { get; } = new BindableList<User>();
|
||||
|
||||
private Bindable<UserActivity> activity { get; } = new Bindable<UserActivity>();
|
||||
|
||||
protected bool HasLogin => authentication.Token.Value != null || (!string.IsNullOrEmpty(ProvidedUsername) && !string.IsNullOrEmpty(password));
|
||||
|
||||
@ -63,10 +67,10 @@ namespace osu.Game.Online.API
|
||||
authentication.TokenString = config.Get<string>(OsuSetting.Token);
|
||||
authentication.Token.ValueChanged += onTokenChanged;
|
||||
|
||||
LocalUser.BindValueChanged(u =>
|
||||
localUser.BindValueChanged(u =>
|
||||
{
|
||||
u.OldValue?.Activity.UnbindFrom(Activity);
|
||||
u.NewValue.Activity.BindTo(Activity);
|
||||
u.OldValue?.Activity.UnbindFrom(activity);
|
||||
u.NewValue.Activity.BindTo(activity);
|
||||
}, true);
|
||||
|
||||
var thread = new Thread(run)
|
||||
@ -138,10 +142,10 @@ namespace osu.Game.Online.API
|
||||
var userReq = new GetUserRequest();
|
||||
userReq.Success += u =>
|
||||
{
|
||||
LocalUser.Value = u;
|
||||
localUser.Value = u;
|
||||
|
||||
// todo: save/pull from settings
|
||||
LocalUser.Value.Status.Value = new UserStatusOnline();
|
||||
localUser.Value.Status.Value = new UserStatusOnline();
|
||||
|
||||
failureCount = 0;
|
||||
|
||||
@ -343,7 +347,7 @@ namespace osu.Game.Online.API
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsLoggedIn => LocalUser.Value.Id > 1;
|
||||
public bool IsLoggedIn => localUser.Value.Id > 1;
|
||||
|
||||
public void Queue(APIRequest request)
|
||||
{
|
||||
@ -376,8 +380,8 @@ namespace osu.Game.Online.API
|
||||
// Scheduled prior to state change such that the state changed event is invoked with the correct user and their friends present
|
||||
Schedule(() =>
|
||||
{
|
||||
LocalUser.Value = createGuestUser();
|
||||
Friends.Clear();
|
||||
localUser.Value = createGuestUser();
|
||||
friends.Clear();
|
||||
});
|
||||
|
||||
state.Value = APIState.Offline;
|
||||
|
Reference in New Issue
Block a user