@page "/" @using Shogi.Contracts.Types @using System.Net.WebSockets @using System.Text @inject AccountManager AccountManager @inject AccountState Account
@if (welcomeModalIsVisible) { } @if (Account.User == null || activeSessionName == null) { } else { }
@code { private bool welcomeModalIsVisible; private string activeSessionName; private ClientWebSocket socket; public Home() { welcomeModalIsVisible = false; activeSessionName = string.Empty; socket = new ClientWebSocket(); } protected override async Task OnInitializedAsync() { Account.LoginChangedEvent += OnLoginChanged; var success = await AccountManager.TryLoginSilentAsync(); if (!success) { welcomeModalIsVisible = true; } } private Task OnLoginChanged(LoginEventArgs args) { welcomeModalIsVisible = args.User == null; StateHasChanged(); return Task.CompletedTask; } private void OnChangeSession(SessionMetadata s) { activeSessionName = s.Name; StateHasChanged(); } }