mirror of
https://github.com/ppy/osu
synced 2024-12-14 02:46:27 +00:00
simplify socialoverlay user request structure
This commit is contained in:
parent
8a02900c01
commit
72af5bf672
@ -140,8 +140,7 @@ namespace osu.Game.Overlays
|
||||
});
|
||||
}
|
||||
|
||||
private GetUsersRequest getUsersRequest;
|
||||
private GetFriendsRequest getFriendsRequest;
|
||||
private APIRequest getUsersRequest;
|
||||
|
||||
private readonly Bindable<string> currentQuery = new Bindable<string>();
|
||||
|
||||
@ -156,7 +155,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
Users = null;
|
||||
loading.Hide();
|
||||
clearRequests();
|
||||
getUsersRequest?.Cancel();
|
||||
|
||||
if (api == null || api.State == APIState.Offline)
|
||||
return;
|
||||
@ -165,24 +164,17 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
case SocialTab.OnlinePlayers:
|
||||
getUsersRequest = new GetUsersRequest(); // TODO filter???
|
||||
getUsersRequest.Success += response => finishRequest(response.Select(r => r.User));
|
||||
queueRequest(getUsersRequest);
|
||||
((GetUsersRequest)getUsersRequest).Success += response => finishRequest(response.Select(r => r.User));
|
||||
break;
|
||||
case SocialTab.OnlineFriends:
|
||||
getFriendsRequest = new GetFriendsRequest(); // TODO filter???
|
||||
getFriendsRequest.Success += finishRequest;
|
||||
queueRequest(getFriendsRequest);
|
||||
getUsersRequest = new GetFriendsRequest(); // TODO filter???
|
||||
((GetFriendsRequest)getUsersRequest).Success += finishRequest;
|
||||
break;
|
||||
}
|
||||
api.Queue(getUsersRequest);
|
||||
loading.Show();
|
||||
}
|
||||
|
||||
private void clearRequests()
|
||||
{
|
||||
getUsersRequest?.Cancel();
|
||||
getFriendsRequest?.Cancel();
|
||||
}
|
||||
|
||||
private void finishRequest(IEnumerable<User> newUsers)
|
||||
{
|
||||
Task.Run(() =>
|
||||
@ -195,11 +187,8 @@ namespace osu.Game.Overlays
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void queueRequest(APIRequest request) => api.Queue(request);
|
||||
}
|
||||
|
||||
|
||||
public enum SortDirection
|
||||
{
|
||||
Descending,
|
||||
|
Loading…
Reference in New Issue
Block a user