Merge pull request #7876 from smoogipoo/fix-playlist-id

Fix playlist items added with the wrong IDs
This commit is contained in:
Dean Herbert 2020-02-17 17:58:26 +09:00 committed by GitHub
commit cf973f7730
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -134,6 +134,22 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddAssert("playlist has 2 items", () => Room.Playlist.Count == 2);
}
[Test]
public void TestAddItemAfterRearrangement()
{
AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem());
AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem());
AddStep("rearrange", () =>
{
var item = Room.Playlist[0];
Room.Playlist.RemoveAt(0);
Room.Playlist.Add(item);
});
AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem());
AddAssert("new item has id 2", () => Room.Playlist.Last().ID == 2);
}
private class TestMatchSongSelect : MatchSongSelect
{
public new MatchBeatmapDetailArea BeatmapDetails => (MatchBeatmapDetailArea)base.BeatmapDetails;

View File

@ -62,7 +62,7 @@ namespace osu.Game.Screens.Select
{
PlaylistItem item = new PlaylistItem
{
ID = (Playlist.LastOrDefault()?.ID + 1) ?? 0,
ID = Playlist.Count == 0 ? 0 : Playlist.Max(p => p.ID) + 1
};
populateItemFromCurrent(item);