1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 11:42:56 +08:00

Remove collection ToLive helper method to avoid confusion

This commit is contained in:
Dean Herbert 2022-01-26 18:25:27 +09:00
parent d1a2256262
commit 45636ce04b
2 changed files with 11 additions and 13 deletions

View File

@ -216,12 +216,6 @@ namespace osu.Game.Database
return new RealmLiveUnmanaged<T>(realmObject);
}
public static List<Live<T>> ToLive<T>(this IEnumerable<T> realmList, RealmAccess realm)
where T : RealmObject, IHasGuidPrimaryKey
{
return realmList.Select(l => new RealmLive<T>(l, realm)).Cast<Live<T>>().ToList();
}
public static Live<T> ToLive<T>(this T realmObject, RealmAccess realm)
where T : RealmObject, IHasGuidPrimaryKey
{

View File

@ -42,7 +42,7 @@ namespace osu.Game.Overlays.Settings.Sections
Name = "<Random Skin>",
}.ToLiveUnmanaged();
private List<Live<SkinInfo>> skinItems;
private readonly List<Live<SkinInfo>> dropdownItems = new List<Live<SkinInfo>>();
[Resolved]
private SkinManager skins { get; set; }
@ -111,19 +111,23 @@ namespace osu.Game.Overlays.Settings.Sections
configBindable.Value = skin.NewValue.ID.ToString();
}
private void skinsChanged(IRealmCollection<SkinInfo> skins, ChangeSet changes, Exception error)
private void skinsChanged(IRealmCollection<SkinInfo> sender, ChangeSet changes, Exception error)
{
// This can only mean that realm is recycling, else we would see the protected skins.
// Because we are using `Live<>` in this class, we don't need to worry about this scenario too much.
if (!skins.Any())
if (!sender.Any())
return;
int protectedCount = skins.Count(s => s.Protected);
int protectedCount = sender.Count(s => s.Protected);
skinItems = skins.ToLive(realm);
skinItems.Insert(protectedCount, random_skin_info);
// For simplicity repopulate the full list.
// In the future we should change this to properly handle ChangeSet events.
dropdownItems.Clear();
foreach (var skin in sender)
dropdownItems.Add(skin.ToLive(realm));
dropdownItems.Insert(protectedCount, random_skin_info);
skinDropdown.Items = skinItems;
skinDropdown.Items = dropdownItems;
updateSelectedSkinFromConfig();
}