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) private void collectionsChanged(IRealmCollection<BeatmapCollection> collections, ChangeSet? changes)
{ {
Items.Clear(); if (changes == null)
Items.AddRange(collections.AsEnumerable().Select(c => c.ToLive(realm))); {
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) protected override OsuRearrangeableListItem<Live<BeatmapCollection>> CreateOsuDrawable(Live<BeatmapCollection> item)