Skip to content

Commit

Permalink
Fixed ExitGatePicker component
Browse files Browse the repository at this point in the history
  • Loading branch information
sven-n committed Dec 6, 2024
1 parent 164bdb7 commit 24f774b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
9 changes: 6 additions & 3 deletions src/Persistence/EntityFramework/TypedContext{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ internal class TypedContext<T> : 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<Type, Type[]> AdditionalTypes = new Dictionary<Type, Type[]>
{
{ 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)
Expand Down Expand Up @@ -137,6 +138,8 @@ private static IEnumerable<IMutableEntityType> DetermineNavigationTypes(IMutable
}
else
{
// We include the type, but don't go any deeper
yield return type;
continue;
}

Expand Down
12 changes: 4 additions & 8 deletions src/Web/AdminPanel/Components/ExitGatePicker.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
/// Blazor component which allows to select an exit gate.
Expand Down Expand Up @@ -46,9 +45,6 @@ public partial class ExitGatePicker
[Parameter]
public EventCallback<ExitGate>? SelectedGateChanged { get; set; }

[Inject]
private ILookupController LookupController { get; set; } = null!;

private GameMapDefinition? Map
{
get => this._map;
Expand Down Expand Up @@ -77,8 +73,8 @@ protected override void OnParametersSet()
/// <inheritdoc />
protected override async Task OnInitializedAsync()
{
this._maps = (await this.LookupController.GetSuggestionsAsync<GameMapDefinition>(string.Empty, null)).OrderBy(c => c.Number).ToList();
await base.OnInitializedAsync();
this._maps = (await this.PersistenceContext.GetAsync<GameMapDefinition>().ConfigureAwait(false)).OrderBy(c => c.Number).ToList();
await base.OnInitializedAsync().ConfigureAwait(false);
}

private string GetCssClass(Gate gate)
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 24f774b

Please sign in to comment.