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:
parent
99c1ba19aa
commit
bc2a15db96
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user