@page "/settings/about" @using System.Text @using Iceshrimp.Assets.PhosphorIcons @using Iceshrimp.Frontend.Core.InMemoryLogger @using Iceshrimp.Frontend.Core.Services @using Iceshrimp.Frontend.Localization @using Iceshrimp.Shared.Schemas.Web @using Microsoft.AspNetCore.Authorization @using Microsoft.Extensions.Localization @using Microsoft.AspNetCore.Components.Sections @attribute [Authorize] @layout SettingsLayout; @inject VersionService Version; @inject IStringLocalizer Loc; @inject IJSRuntime Js; @inject InMemoryLogService LogSvc; @inject UpdateService UpdateSvc; @inject NavigationManager Nav; @inject ILogger Logger; @Loc["About"]

@Loc["Version Information"]

Iceshrimp.NET @Version.Version Codename @Version.Codename @if (Version.CommitHash != null) { Commit @Version.CommitHash } .NET Runtime @Environment.Version
@if (_updateAvailable == CheckState.True) {
New version!
Iceshrimp.NET @_newVersion?.Version Codename @_newVersion?.Codename @if (_newVersion?.CommitHash != null) { Commit @_newVersion?.CommitHash }
@if (_skipWaitingRes == CheckState.Error) {
@Loc["Something went wrong while loading the update, please check the logs."]
} } @if (_updateAvailable == CheckState.False) {
@Loc["Already on the newest version!"]
} @if (_updateAvailable == CheckState.Error) {
@Loc["Failed to check for updates."]
}

@Loc["Logs"]

@Loc["These logs may contain sensitive information, please do not post them publicly.\n" + "Providing them to developers upon request may help with debugging."]
@code { private IJSInProcessObjectReference _module = null!; private CheckState _updateAvailable = CheckState.Unknown; private CheckState _skipWaitingRes = CheckState.Unknown; private VersionResponse? _newVersion; protected override async Task OnInitializedAsync() { _module = (IJSInProcessObjectReference)await Js.InvokeAsync("import", "./Components/ErrorUi.razor.js"); await CheckUpdate(); } private enum CheckState { Unknown, True, False, Error } private async Task CheckUpdate() { try { await UpdateSvc.ServiceWorkerUpdateAsync(); } catch (Exception e) { Logger.LogError(e, "Failed to check for updates."); _updateAvailable = CheckState.Error; return; } var res = await UpdateSvc.ServiceWorkerCheckWaitingAsync(); _updateAvailable = res ? CheckState.True : CheckState.False; _newVersion = UpdateSvc.BackendVersion; StateHasChanged(); } private async Task SkipWaiting() { var res = await UpdateSvc.ServiceWorkerSkipWaitingAsync(); _skipWaitingRes = res ? CheckState.True : CheckState.Error; if (res) { Nav.NavigateTo("/", true); } } private void DownloadLogs() { var logBytes = LogSvc.GetLogs().SelectMany(p => Encoding.UTF8.GetBytes(p)).ToArray(); _module.InvokeVoid("DownloadFile", "log.txt", "text/plain", logBytes); } }