From 24f774b1fe6b3d42d6b9f0a335ab97d247e7217e Mon Sep 17 00:00:00 2001 From: sven-n Date: Fri, 6 Dec 2024 21:15:32 +0100 Subject: [PATCH] Fixed ExitGatePicker component --- src/Persistence/EntityFramework/TypedContext{T}.cs | 9 ++++++--- .../AdminPanel/Components/ExitGatePicker.razor.cs | 12 ++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Persistence/EntityFramework/TypedContext{T}.cs b/src/Persistence/EntityFramework/TypedContext{T}.cs index 082bab1d6..77c531582 100644 --- a/src/Persistence/EntityFramework/TypedContext{T}.cs +++ b/src/Persistence/EntityFramework/TypedContext{T}.cs @@ -19,9 +19,10 @@ internal class TypedContext : EntityDataContext, ITypedContext // ReSharper disable once StaticMemberInGenericType That's okay. We don't need the behavior, but introducing a base class is just too much boilerplate. private static readonly IReadOnlyDictionary AdditionalTypes = new Dictionary { - { typeof(GameServerDefinition), new[] { typeof(GameServerConfiguration) } }, - { typeof(GameServerEndpoint), new[] { typeof(GameClientDefinition) } }, - { typeof(ConnectServerDefinition), new[] { typeof(GameClientDefinition) } }, + { typeof(GameServerDefinition), [typeof(GameServerConfiguration)] }, + { typeof(GameServerEndpoint), [typeof(GameClientDefinition)] }, + { typeof(ConnectServerDefinition), [typeof(GameClientDefinition)] }, + { typeof(DuelArea), [typeof(GameMapDefinition)] }, }; // ReSharper disable once StaticMemberInGenericType That's okay, we want this behavior (each type context with it's own set) @@ -137,6 +138,8 @@ private static IEnumerable DetermineNavigationTypes(IMutable } else { + // We include the type, but don't go any deeper + yield return type; continue; } diff --git a/src/Web/AdminPanel/Components/ExitGatePicker.razor.cs b/src/Web/AdminPanel/Components/ExitGatePicker.razor.cs index 5b77fecc5..51a831648 100644 --- a/src/Web/AdminPanel/Components/ExitGatePicker.razor.cs +++ b/src/Web/AdminPanel/Components/ExitGatePicker.razor.cs @@ -10,9 +10,8 @@ namespace MUnique.OpenMU.Web.AdminPanel.Components; using MUnique.OpenMU.GameLogic; using MUnique.OpenMU.Persistence; using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Formats.Png; -using MUnique.OpenMU.Web.AdminPanel.Services; +using SixLabors.ImageSharp.PixelFormats; /// /// Blazor component which allows to select an exit gate. @@ -46,9 +45,6 @@ public partial class ExitGatePicker [Parameter] public EventCallback? SelectedGateChanged { get; set; } - [Inject] - private ILookupController LookupController { get; set; } = null!; - private GameMapDefinition? Map { get => this._map; @@ -77,8 +73,8 @@ protected override void OnParametersSet() /// protected override async Task OnInitializedAsync() { - this._maps = (await this.LookupController.GetSuggestionsAsync(string.Empty, null)).OrderBy(c => c.Number).ToList(); - await base.OnInitializedAsync(); + this._maps = (await this.PersistenceContext.GetAsync().ConfigureAwait(false)).OrderBy(c => c.Number).ToList(); + await base.OnInitializedAsync().ConfigureAwait(false); } private string GetCssClass(Gate gate) @@ -115,7 +111,7 @@ private async Task OnGateSelectedAsync(ChangeEventArgs args) if (Guid.TryParse(args.Value as string, out var gateId) && this.Map?.ExitGates.FirstOrDefault(g => g.GetId() == gateId) is { } gate) { - await this.OnSelectedAsync(gate); + await this.OnSelectedAsync(gate).ConfigureAwait(false); } }