1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-05 20:42:55 +08:00

Change collection management dialog to handle changes more correctly

This commit is contained in:
Dean Herbert 2024-11-14 14:12:13 +09:00
parent 5cc1cbe880
commit 695f156f5f
No known key found for this signature in database

View File

@ -43,8 +43,25 @@ namespace osu.Game.Collections
private void collectionsChanged(IRealmCollection<BeatmapCollection> collections, ChangeSet? changes)
{
Items.Clear();
Items.AddRange(collections.AsEnumerable().Select(c => c.ToLive(realm)));
if (changes == null)
{
Items.AddRange(collections.AsEnumerable().Select(c => c.ToLive(realm)));
return;
}
foreach (int i in changes.DeletedIndices.OrderDescending())
Items.RemoveAt(i);
foreach (int i in changes.InsertedIndices)
Items.Insert(i, collections[i].ToLive(realm));
foreach (int i in changes.NewModifiedIndices)
{
var updatedItem = collections[i];
Items.RemoveAt(i);
Items.Insert(i, updatedItem.ToLive(realm));
}
}
protected override OsuRearrangeableListItem<Live<BeatmapCollection>> CreateOsuDrawable(Live<BeatmapCollection> item)