@inherits LayoutComponentBase @inject GPW.CORE.Services.UserStateService UState @inject ILogger Log GPW.CORE.Smart (Client)
@Body
@if (dataLoaded) { }
An unhandled error has occurred. Reload 🗙
@code { private readonly Guid _instanceId = Guid.NewGuid(); private bool _subscribed; private bool isIpLocal = false; private bool dataLoaded = true; private UserDTO? currUser; private ConfigDTO? currConfig; private int idxDip { get => (currUser != null && currUser?.IdxDip != null) ? (int)currUser?.IdxDip : 0; } protected override void OnInitialized() { Log.LogInformation("MainLayout OnInitialized client instance {Id}", _instanceId); } protected override async Task OnAfterRenderAsync(bool firstRender) { if (!firstRender) return; Log.LogInformation("MainLayout OnAfterRenderAsync firstRender client instance {Id}, CurrentUser {User}", _instanceId, UState.CurrentUser?.Utente ?? ""); if (!_subscribed) { UState.OnChange += UState_OnChange; _subscribed = true; Log.LogInformation("MainLayout subscribed to UserState in client instance {Id}", _instanceId); } if (UState.CurrentUser != null) { currUser = UState.CurrentUser; await InvokeAsync(StateHasChanged); } } private void UState_OnChange() { _ = InvokeAsync(() => { Log.LogInformation("MainLayout UState_OnChange client instance {Id} invoked", _instanceId); currUser = UState.CurrentUser; StateHasChanged(); }); } public void Dispose() { if (_subscribed) { UState.OnChange -= UState_OnChange; _subscribed = false; Log.LogInformation("MainLayout unsubscribed in Dispose client instance {Id}", _instanceId); } } private Task ReturnHome() => Task.CompletedTask; private Task ForceReset() => Task.CompletedTask; }