Add friends list to API providers

This commit is contained in:
Salman Ahmed
2020-12-17 13:30:55 +03:00
parent 76ffe31855
commit 78ce6f1cd2
3 changed files with 25 additions and 2 deletions

View File

@ -41,6 +41,8 @@ namespace osu.Game.Online.API
public Bindable<User> LocalUser { get; } = new Bindable<User>(createGuestUser());
public BindableList<User> Friends { get; } = new BindableList<User>();
public Bindable<UserActivity> Activity { get; } = new Bindable<UserActivity>();
protected bool HasLogin => authentication.Token.Value != null || (!string.IsNullOrEmpty(ProvidedUsername) && !string.IsNullOrEmpty(password));
@ -143,6 +145,10 @@ namespace osu.Game.Online.API
failureCount = 0;
var friendsReq = new GetFriendsRequest();
friendsReq.Success += f => Friends.AddRange(f);
handleRequest(friendsReq);
//we're connected!
state.Value = APIState.Online;
};
@ -352,8 +358,12 @@ namespace osu.Game.Online.API
password = null;
authentication.Clear();
// Scheduled prior to state change such that the state changed event is invoked with the correct user present
Schedule(() => LocalUser.Value = createGuestUser());
// 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();
});
state.Value = APIState.Offline;
}