Rename variables for readability

This commit is contained in:
Dan Balasescu 2021-11-16 14:44:47 +09:00
parent f414877d00
commit 01f3649d75

View File

@ -617,7 +617,7 @@ namespace osu.Game.Online.Multiplayer
Debug.Assert(APIRoom != null); Debug.Assert(APIRoom != null);
APIRoom.Playlist.RemoveAll(i => i.ID == playlistItem.ID); APIRoom.Playlist.RemoveAll(existingItem => existingItem.ID == playlistItem.ID);
APIRoom.Playlist.Add(playlistItem); APIRoom.Playlist.Add(playlistItem);
RoomUpdated?.Invoke(); RoomUpdated?.Invoke();
}); });
@ -635,7 +635,7 @@ namespace osu.Game.Online.Multiplayer
Debug.Assert(APIRoom != null); Debug.Assert(APIRoom != null);
APIRoom.Playlist.RemoveAll(i => i.ID == playlistItemId); APIRoom.Playlist.RemoveAll(item => item.ID == playlistItemId);
RoomUpdated?.Invoke(); RoomUpdated?.Invoke();
}); });
@ -656,18 +656,18 @@ namespace osu.Game.Online.Multiplayer
Debug.Assert(APIRoom != null); Debug.Assert(APIRoom != null);
int index = APIRoom.Playlist.Select((i, index) => (i, index)).Single(kvp => kvp.i.ID == item.ID).index; PlaylistItem existingItem = APIRoom.Playlist.Single(existingItem => existingItem.ID == item.ID);
var oldItem = APIRoom.Playlist[index]; int existingIndex = APIRoom.Playlist.IndexOf(existingItem);
if (oldItem.Equals(playlistItem)) if (existingItem.Equals(playlistItem))
return; return;
// Replace the item. // Replace the item.
APIRoom.Playlist.RemoveAt(index); APIRoom.Playlist.RemoveAt(existingIndex);
APIRoom.Playlist.Insert(index, playlistItem); APIRoom.Playlist.Insert(existingIndex, playlistItem);
// If the currently-selected item was the one that got replaced, update the selected item to the new one. // If the currently-selected item was the one that got replaced, update the selected item to the new one.
if (CurrentMatchPlayingItem.Value == oldItem) if (CurrentMatchPlayingItem.Value == existingItem)
CurrentMatchPlayingItem.Value = APIRoom.Playlist[index]; CurrentMatchPlayingItem.Value = playlistItem;
RoomUpdated?.Invoke(); RoomUpdated?.Invoke();
}); });