1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 16:37:26 +08:00

Use method instead of property for realm query retrieval

This commit is contained in:
Dean Herbert 2022-01-23 18:01:39 +09:00
parent 70a120ea8a
commit bd0eda7e90

View File

@ -46,19 +46,16 @@ namespace osu.Game.Input.Bindings
throw new InvalidOperationException($"{nameof(variant)} can not be null when a non-null {nameof(ruleset)} is provided."); throw new InvalidOperationException($"{nameof(variant)} can not be null when a non-null {nameof(ruleset)} is provided.");
} }
private IQueryable<RealmKeyBinding> realmKeyBindings private IQueryable<RealmKeyBinding> queryRealmKeyBindings()
{
get
{ {
string rulesetName = ruleset?.ShortName; string rulesetName = ruleset?.ShortName;
return realmFactory.Context.All<RealmKeyBinding>() return realmFactory.Context.All<RealmKeyBinding>()
.Where(b => b.RulesetName == rulesetName && b.Variant == variant); .Where(b => b.RulesetName == rulesetName && b.Variant == variant);
} }
}
protected override void LoadComplete() protected override void LoadComplete()
{ {
realmSubscription = realmFactory.Register(realm => realmKeyBindings realmSubscription = realmFactory.Register(realm => queryRealmKeyBindings()
.QueryAsyncWithNotifications((sender, changes, error) => .QueryAsyncWithNotifications((sender, changes, error) =>
{ {
// The first fire of this is a bit redundant as this is being called in base.LoadComplete, // The first fire of this is a bit redundant as this is being called in base.LoadComplete,
@ -80,7 +77,7 @@ namespace osu.Game.Input.Bindings
{ {
var defaults = DefaultKeyBindings.ToList(); var defaults = DefaultKeyBindings.ToList();
List<RealmKeyBinding> newBindings = realmKeyBindings.Detach() List<RealmKeyBinding> newBindings = queryRealmKeyBindings().Detach()
// this ordering is important to ensure that we read entries from the database in the order // this ordering is important to ensure that we read entries from the database in the order
// enforced by DefaultKeyBindings. allow for song select to handle actions that may otherwise // enforced by DefaultKeyBindings. allow for song select to handle actions that may otherwise
// have been eaten by the music controller due to query order. // have been eaten by the music controller due to query order.