1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 10:23:02 +08:00

Reforamt for legibility

This commit is contained in:
Dean Herbert 2020-11-09 12:22:54 +09:00
parent dc69eefa51
commit 690e69bcc6

View File

@ -53,40 +53,43 @@ namespace osu.Game.Overlays.Dashboard
base.LoadComplete(); base.LoadComplete();
playingUsers.BindTo(spectatorStreaming.PlayingUsers); playingUsers.BindTo(spectatorStreaming.PlayingUsers);
playingUsers.BindCollectionChanged((sender, e) => Schedule(() => playingUsers.BindCollectionChanged(onUsersChanged, true);
{ }
switch (e.Action)
{
case NotifyCollectionChangedAction.Add:
foreach (var id in e.NewItems.OfType<int>().ToArray()) private void onUsersChanged(object sender, NotifyCollectionChangedEventArgs e) => Schedule(() =>
{
switch (e.Action)
{
case NotifyCollectionChangedAction.Add:
foreach (var id in e.NewItems.OfType<int>().ToArray())
{
users.GetUserAsync(id).ContinueWith(u =>
{ {
users.GetUserAsync(id).ContinueWith(u => if (u.Result == null) return;
Schedule(() =>
{ {
if (u.Result == null) // user may no longer be playing.
if (!playingUsers.Contains(u.Result.Id))
return; return;
Schedule(() => userFlow.Add(createUserPanel(u.Result));
{
if (playingUsers.Contains(u.Result.Id))
userFlow.Add(createUserPanel(u.Result));
});
}); });
} });
}
break; break;
case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Remove:
foreach (var u in e.OldItems.OfType<int>()) foreach (var u in e.OldItems.OfType<int>())
userFlow.FirstOrDefault(card => card.User.Id == u)?.Expire(); userFlow.FirstOrDefault(card => card.User.Id == u)?.Expire();
break; break;
case NotifyCollectionChangedAction.Reset: case NotifyCollectionChangedAction.Reset:
userFlow.Clear(); userFlow.Clear();
break; break;
} }
}), true); });
}
private PlayingUserPanel createUserPanel(User user) => private PlayingUserPanel createUserPanel(User user) =>
new PlayingUserPanel(user).With(panel => new PlayingUserPanel(user).With(panel =>