LANCommander/LANCommander.Launcher/UI/Components/AuthenticatedView.razor

27 lines
No EOL
832 B
Text

@using ConnectionState = LANCommander.Launcher.Models.ConnectionState
@inject AuthenticationService AuthenticationService
@inject NavigationManager NavigationManager
<CascadingValue Value="ConnectionState">
@if (ConnectionState.IsConnected || ConnectionState.OfflineModeEnabled)
{
@Authenticated
}
else
{
@NotAuthenticated
}
</CascadingValue>
@code {
[Parameter] public RenderFragment Authenticated { get; set; }
[Parameter] public RenderFragment NotAuthenticated { get; set; }
public ConnectionState ConnectionState = new();
protected override async Task OnInitializedAsync()
{
ConnectionState.IsConnected = await AuthenticationService.ValidateConnectionAsync();
ConnectionState.OfflineModeEnabled = AuthenticationService.OfflineModeEnabled();
}
}