@using ConnectionState = LANCommander.Launcher.Models.ConnectionState @inject AuthenticationService AuthenticationService @inject NavigationManager NavigationManager @if (ConnectionState.IsConnected || ConnectionState.OfflineModeEnabled) { @Authenticated } else { @NotAuthenticated } @code { [Parameter] public RenderFragment Authenticated { get; set; } [Parameter] public RenderFragment NotAuthenticated { get; set; } public ConnectionState ConnectionState = new(); protected override async Task OnInitializedAsync() { AuthenticationService.OnLogin += async (sender, args) => { await Validate(); }; AuthenticationService.OnRegister += async (sender, args) => { await Validate(); }; await Validate(); } public async Task Validate() { ConnectionState.IsConnected = await AuthenticationService.ValidateConnectionAsync(); ConnectionState.OfflineModeEnabled = AuthenticationService.OfflineModeEnabled(); await InvokeAsync(StateHasChanged); } }