mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Fix various cases of creating realm contexts from update thread when not necessary
This commit is contained in:
@ -98,17 +98,16 @@ namespace osu.Game.Beatmaps
|
||||
/// <returns>The first result for the provided query, or null if no results were found.</returns>
|
||||
public BeatmapInfo? QueryBeatmap(Expression<Func<BeatmapInfo, bool>> query)
|
||||
{
|
||||
using (var context = ContextFactory.CreateContext())
|
||||
return context.All<BeatmapInfo>().FirstOrDefault(query)?.Detach();
|
||||
return ContextFactory.Run(realm => realm.All<BeatmapInfo>().FirstOrDefault(query)?.Detach());
|
||||
}
|
||||
|
||||
public void Update(BeatmapSetInfo item)
|
||||
{
|
||||
using (var realm = ContextFactory.CreateContext())
|
||||
ContextFactory.Run(realm =>
|
||||
{
|
||||
var existing = realm.Find<BeatmapSetInfo>(item.ID);
|
||||
realm.Write(r => item.CopyChangesToRealm(existing));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user