mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Move activity (writable) bindable to APIAccess so it correctly transfers between users
This commit is contained in:
@ -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",
|
||||
|
@ -17,6 +17,8 @@ namespace osu.Game.Online.API
|
||||
Id = 1001,
|
||||
});
|
||||
|
||||
public Bindable<UserActivity> Activity { get; } = new Bindable<UserActivity>();
|
||||
|
||||
public bool IsLoggedIn => true;
|
||||
|
||||
public string ProvidedUsername => LocalUser.Value.Username;
|
||||
@ -41,6 +43,15 @@ namespace osu.Game.Online.API
|
||||
}
|
||||
}
|
||||
|
||||
public DummyAPIAccess()
|
||||
{
|
||||
LocalUser.BindValueChanged(u =>
|
||||
{
|
||||
u.OldValue?.Activity.UnbindFrom(Activity);
|
||||
u.NewValue.Activity.BindTo(Activity);
|
||||
}, true);
|
||||
}
|
||||
|
||||
public virtual void Queue(APIRequest request)
|
||||
{
|
||||
}
|
||||
|
@ -13,6 +13,11 @@ namespace osu.Game.Online.API
|
||||
/// </summary>
|
||||
Bindable<User> LocalUser { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The current user's activity.
|
||||
/// </summary>
|
||||
Bindable<UserActivity> Activity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the local user is logged in.
|
||||
/// </summary>
|
||||
|
Reference in New Issue
Block a user