mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:17:23 +08:00
Add friends list to API providers
This commit is contained in:
parent
76ffe31855
commit
78ce6f1cd2
@ -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;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Users;
|
||||
|
||||
@ -18,6 +19,12 @@ namespace osu.Game.Online.API
|
||||
Id = 1001,
|
||||
});
|
||||
|
||||
public BindableList<User> Friends { get; } = new BindableList<User>(new User
|
||||
{
|
||||
Username = @"Dummy's friend",
|
||||
Id = 2002,
|
||||
}.Yield());
|
||||
|
||||
public Bindable<UserActivity> Activity { get; } = new Bindable<UserActivity>();
|
||||
|
||||
public string AccessToken => "token";
|
||||
|
@ -15,6 +15,12 @@ namespace osu.Game.Online.API
|
||||
/// </summary>
|
||||
Bindable<User> LocalUser { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The user's friends.
|
||||
/// This is not thread-safe and should be scheduled locally if consumed from a drawable component.
|
||||
/// </summary>
|
||||
BindableList<User> Friends { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The current user's activity.
|
||||
/// This is not thread-safe and should be scheduled locally if consumed from a drawable component.
|
||||
|
Loading…
Reference in New Issue
Block a user