mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Add ability to lookup multiple users at once to UserLookupCache
This commit is contained in:
@ -5,7 +5,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -61,7 +60,7 @@ namespace osu.Game.Screens.Spectate
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
getAllUsers().ContinueWith(users => Schedule(() =>
|
||||
userLookupCache.GetUsersAsync(userIds.ToArray()).ContinueWith(users => Schedule(() =>
|
||||
{
|
||||
foreach (var u in users.Result)
|
||||
userMap[u.Id] = u;
|
||||
@ -77,24 +76,6 @@ namespace osu.Game.Screens.Spectate
|
||||
}));
|
||||
}
|
||||
|
||||
private Task<User[]> getAllUsers()
|
||||
{
|
||||
var userLookupTasks = new List<Task<User>>();
|
||||
|
||||
foreach (var u in userIds)
|
||||
{
|
||||
userLookupTasks.Add(userLookupCache.GetUserAsync(u).ContinueWith(task =>
|
||||
{
|
||||
if (!task.IsCompletedSuccessfully)
|
||||
return null;
|
||||
|
||||
return task.Result;
|
||||
}));
|
||||
}
|
||||
|
||||
return Task.WhenAll(userLookupTasks);
|
||||
}
|
||||
|
||||
private void beatmapUpdated(ValueChangedEvent<WeakReference<BeatmapSetInfo>> e)
|
||||
{
|
||||
if (!e.NewValue.TryGetTarget(out var beatmapSet))
|
||||
|
Reference in New Issue
Block a user