Reforamt for legibility

This commit is contained in:
Dean Herbert 2020-11-09 12:22:54 +09:00
parent dc69eefa51
commit 690e69bcc6
1 changed files with 28 additions and 25 deletions

View File

@ -53,22 +53,26 @@ protected override void LoadComplete()
base.LoadComplete();
playingUsers.BindTo(spectatorStreaming.PlayingUsers);
playingUsers.BindCollectionChanged((sender, e) => Schedule(() =>
playingUsers.BindCollectionChanged(onUsersChanged, true);
}
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 =>
{
if (u.Result == null)
return;
if (u.Result == null) return;
Schedule(() =>
{
if (playingUsers.Contains(u.Result.Id))
// user may no longer be playing.
if (!playingUsers.Contains(u.Result.Id))
return;
userFlow.Add(createUserPanel(u.Result));
});
});
@ -85,8 +89,7 @@ protected override void LoadComplete()
userFlow.Clear();
break;
}
}), true);
}
});
private PlayingUserPanel createUserPanel(User user) =>
new PlayingUserPanel(user).With(panel =>