1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 06:42:56 +08:00

Handle cases of beatmaps not existing in realm for tests

This commit is contained in:
Dean Herbert 2022-03-01 19:20:18 +09:00
parent 99c1ba19aa
commit bc2a15db96
2 changed files with 12 additions and 3 deletions

View File

@ -88,7 +88,10 @@ namespace osu.Game.Screens.Play
beatmapOffsetSubscription = realm.RegisterCustomSubscription(r =>
{
var userSettings = r.Find<BeatmapInfo>(beatmap.BeatmapInfo.ID).UserSettings;
var userSettings = r.Find<BeatmapInfo>(beatmap.BeatmapInfo.ID)?.UserSettings;
if (userSettings == null) // only the case for tests.
return null;
void onUserSettingsOnPropertyChanged(object sender, PropertyChangedEventArgs args)
{

View File

@ -85,7 +85,10 @@ namespace osu.Game.Screens.Play.PlayerSettings
beatmapOffsetSubscription = realm.RegisterCustomSubscription(r =>
{
var userSettings = r.Find<BeatmapInfo>(beatmap.Value.BeatmapInfo.ID).UserSettings;
var userSettings = r.Find<BeatmapInfo>(beatmap.Value.BeatmapInfo.ID)?.UserSettings;
if (userSettings == null) // only the case for tests.
return null;
Current.Value = userSettings.Offset;
userSettings.PropertyChanged += onUserSettingsOnPropertyChanged;
@ -122,7 +125,10 @@ namespace osu.Game.Screens.Play.PlayerSettings
realmWrite = realm.WriteAsync(r =>
{
var settings = r.Find<BeatmapInfo>(beatmap.Value.BeatmapInfo.ID).UserSettings;
var settings = r.Find<BeatmapInfo>(beatmap.Value.BeatmapInfo.ID)?.UserSettings;
if (settings == null) // only the case for tests.
return;
if (Precision.AlmostEquals(settings.Offset, Current.Value))
return;