Convert realm data propagation to more correctly use Live<T>

wip
This commit is contained in:
Dean Herbert
2022-07-27 17:17:43 +09:00
parent 41393616d8
commit 438067a18b
12 changed files with 54 additions and 40 deletions

View File

@ -2,22 +2,26 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Collections
{
public class CollectionToggleMenuItem : ToggleMenuItem
{
public CollectionToggleMenuItem(BeatmapCollection collection, IBeatmapInfo beatmap)
: base(collection.Name, MenuItemType.Standard, state =>
public CollectionToggleMenuItem(Live<BeatmapCollection> collection, IBeatmapInfo beatmap)
: base(collection.PerformRead(c => c.Name), MenuItemType.Standard, state =>
{
if (state)
collection.BeatmapMD5Hashes.Add(beatmap.MD5Hash);
else
collection.BeatmapMD5Hashes.Remove(beatmap.MD5Hash);
collection.PerformWrite(c =>
{
if (state)
c.BeatmapMD5Hashes.Add(beatmap.MD5Hash);
else
c.BeatmapMD5Hashes.Remove(beatmap.MD5Hash);
});
})
{
State.Value = collection.BeatmapMD5Hashes.Contains(beatmap.MD5Hash);
State.Value = collection.PerformRead(c => c.BeatmapMD5Hashes.Contains(beatmap.MD5Hash));
}
}
}