Move activity (writable) bindable to APIAccess so it correctly transfers between users

This commit is contained in:
Dean Herbert
2019-06-12 18:04:57 +09:00
parent 20b43c20c8
commit f358fce9ab
8 changed files with 40 additions and 13 deletions

View File

@ -37,6 +37,8 @@ namespace osu.Game.Online.API
public Bindable<User> LocalUser { get; } = new Bindable<User>(createGuestUser());
public Bindable<UserActivity> Activity { get; } = new Bindable<UserActivity>();
protected bool HasLogin => authentication.Token.Value != null || (!string.IsNullOrEmpty(ProvidedUsername) && !string.IsNullOrEmpty(password));
private readonly CancellationTokenSource cancellationToken = new CancellationTokenSource();
@ -55,6 +57,12 @@ namespace osu.Game.Online.API
authentication.TokenString = config.Get<string>(OsuSetting.Token);
authentication.Token.ValueChanged += onTokenChanged;
LocalUser.BindValueChanged(u =>
{
u.OldValue?.Activity.UnbindFrom(Activity);
u.NewValue.Activity.BindTo(Activity);
}, true);
var thread = new Thread(run)
{
Name = "APIAccess",