@using System.Reflection @using Microsoft.AspNetCore.Components.Authorization @using Microsoft.AspNetCore.Identity @using Microsoft.AspNetCore.SignalR.Client @using MudBlazor.StaticInput @using OneSwiss.Server.Models @using OneSwiss.Server.Services @inherits LayoutComponentBase @inject ISnackbar SnackbarService @inject IHttpContextAccessor ContextAccessor @inject UpdatesChecker.State UpdatesCheckerState @inject NavigationManager NavManager @inject UserManager UserManager @inject IJSRuntime Js @if (UpdatesCheckerState.UpdatesAvailable) { var text = UpdatesCheckerState?.ReleaseInfo?.Prerelease == true ? "Доступно обновление (pre)" : "Доступно обновление"; @text } @_user?.ToString() @Assembly.GetExecutingAssembly().GetName().Version @Body
An unhandled error has occurred. Reload 🗙
@code { private HubConnection? _hubConnection; bool _isDarkMode = true; NavMenu? _navMenu; bool _drawerOpen = true; readonly MudTheme _theme = new(); private ApplicationUser? _user; protected override async Task OnInitializedAsync() { if (ContextAccessor.HttpContext != null) _user = await UserManager.GetUserAsync(ContextAccessor.HttpContext.User); SnackbarService.Configuration.PositionClass = Defaults.Classes.Position.BottomEnd; if (ContextAccessor.HttpContext?.Request.Cookies.TryGetValue("IsDarkMode", out var value) == true && bool.TryParse(value, out var isDarkMode)) _isDarkMode = isDarkMode; _hubConnection = new HubConnectionBuilder() .WithUrl(NavManager.ToAbsoluteUri("/updatesHub")) .Build(); _hubConnection.On("UpdatesAvailable", async () => { await InvokeAsync(StateHasChanged); }); await _hubConnection.StartAsync(); } private async Task SetIsDarkModeCookie() { await Js.InvokeVoidAsync("blazorSetCookie", "IsDarkMode", _isDarkMode, 7, false); } private async Task OnChangeTheme() { await SetIsDarkModeCookie(); } private async Task GoToReleasePage() { if (UpdatesCheckerState.ReleaseInfo != null) await Js.InvokeVoidAsync("open", UpdatesCheckerState.ReleaseInfo.HtmlUrl, "_blank"); } }