mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Add and consume multi-lookup API endpoint
This commit is contained in:
19
osu.Game/Online/API/Requests/GetUsersRequest.cs
Normal file
19
osu.Game/Online/API/Requests/GetUsersRequest.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.API.Requests
|
||||||
|
{
|
||||||
|
public class GetUsersRequest : APIRequest<GetUsersResponse>
|
||||||
|
{
|
||||||
|
private readonly int[] userIds;
|
||||||
|
|
||||||
|
public GetUsersRequest(int[] userIds)
|
||||||
|
{
|
||||||
|
this.userIds = userIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string Target => $@"users/?{userIds.Select(u => $"ids[]={u}&").Aggregate((a, b) => a + b)}";
|
||||||
|
}
|
||||||
|
}
|
15
osu.Game/Online/API/Requests/GetUsersResponse.cs
Normal file
15
osu.Game/Online/API/Requests/GetUsersResponse.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using osu.Game.Users;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.API.Requests
|
||||||
|
{
|
||||||
|
public class GetUsersResponse : ResponseWithCursor
|
||||||
|
{
|
||||||
|
[JsonProperty("users")]
|
||||||
|
public List<User> Users;
|
||||||
|
}
|
||||||
|
}
|
@ -54,17 +54,18 @@ namespace osu.Game.Overlays.Dashboard
|
|||||||
switch (e.Action)
|
switch (e.Action)
|
||||||
{
|
{
|
||||||
case NotifyCollectionChangedAction.Add:
|
case NotifyCollectionChangedAction.Add:
|
||||||
foreach (var u in e.NewItems.OfType<int>())
|
var request = new GetUsersRequest(e.NewItems.OfType<int>().ToArray());
|
||||||
|
|
||||||
|
request.Success += users => Schedule(() =>
|
||||||
{
|
{
|
||||||
var request = new GetUserRequest(u);
|
foreach (var user in users.Users)
|
||||||
request.Success += user => Schedule(() =>
|
|
||||||
{
|
{
|
||||||
if (playingUsers.Contains(user.Id))
|
if (playingUsers.Contains(user.Id))
|
||||||
userFlow.Add(createUserPanel(user));
|
userFlow.Add(createUserPanel(user));
|
||||||
});
|
}
|
||||||
api.Queue(request);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
|
api.Queue(request);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NotifyCollectionChangedAction.Remove:
|
case NotifyCollectionChangedAction.Remove:
|
||||||
|
@ -131,8 +131,7 @@ namespace osu.Game.Overlays
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case DashboardOverlayTabs.CurrentlyPlaying:
|
case DashboardOverlayTabs.CurrentlyPlaying:
|
||||||
//todo: enable once caching logic is better
|
loadDisplay(new CurrentlyPlayingDisplay());
|
||||||
//loadDisplay(new CurrentlyPlayingDisplay());
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Reference in New Issue
Block a user