Don't replace identical playlist items

This commit is contained in:
smoogipoo
2021-10-29 16:44:39 +09:00
parent f732c44265
commit 2408011c81
2 changed files with 22 additions and 5 deletions

View File

@ -623,11 +623,16 @@ namespace osu.Game.Online.Multiplayer
Debug.Assert(APIRoom != null);
int index = APIRoom.Playlist.Select((i, index) => (i, index)).Single(kvp => kvp.i.ID == item.ID).index;
var oldItem = APIRoom.Playlist[index];
if (oldItem.Equals(playlistItem))
return;
// Replace the item.
APIRoom.Playlist.RemoveAt(index);
APIRoom.Playlist.Insert(index, playlistItem);
// If the current item changed, update the selected playlist item.
if (item.ID == Room.Settings.PlaylistItemId)
// If the currently-selected item was the one that got replaced, update the selected item to the new one.
if (CurrentMatchPlayingItem.Value == oldItem)
CurrentMatchPlayingItem.Value = APIRoom.Playlist[index];
}).ConfigureAwait(false);
}