mirror of
https://github.com/ppy/osu.git
synced 2026-05-17 13:23:00 +08:00
cb9d9734d6
Probably closes https://github.com/ppy/osu/issues/35650. Realm slow, episode 23894. I can't reproduce freezes as big as the video in the issue is showing but 'realm slow' is 99% the culprit, because affected user's database is not small.
29 lines
1000 B
C#
29 lines
1000 B
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
using System.Threading.Tasks;
|
|
using osu.Game.Beatmaps;
|
|
using osu.Game.Database;
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
namespace osu.Game.Collections
|
|
{
|
|
public class CollectionToggleMenuItem : ToggleMenuItem
|
|
{
|
|
public CollectionToggleMenuItem(Live<BeatmapCollection> collection, IBeatmapInfo beatmap)
|
|
: base(collection.PerformRead(c => c.Name), MenuItemType.Standard, state => Task.Run(() =>
|
|
{
|
|
collection.PerformWrite(c =>
|
|
{
|
|
if (state)
|
|
c.BeatmapMD5Hashes.Add(beatmap.MD5Hash);
|
|
else
|
|
c.BeatmapMD5Hashes.Remove(beatmap.MD5Hash);
|
|
});
|
|
}))
|
|
{
|
|
State.Value = collection.PerformRead(c => c.BeatmapMD5Hashes.Contains(beatmap.MD5Hash));
|
|
}
|
|
}
|
|
}
|