@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 @using Iceshrimp.Frontend.Components @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; @implements IDisposable; @Loc["About"]

@Loc["Version Information"]

Iceshrimp.NET @Version.Version Codename @Version.Codename @if (Version.CommitHash != null) { Commit @Version.CommitHash } .NET Runtime @Environment.Version
@Loc["No Update available"] @Loc["Check for updates"] @Loc["Update Loading"] @Loc["Failed to check for updates"] @if (_updateState == UpdateState.Installed) {
New version!
Iceshrimp.NET @_newVersion?.Version Codename @_newVersion?.Codename @if (_newVersion?.CommitHash != null) { Commit @_newVersion?.CommitHash }
} @if (_updateState == UpdateState.NoUpdate) {
@Loc["Already on the newest version!"]
}

@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 UpdateState _updateState = UpdateState.Unknown; private VersionResponse? _newVersion; private StateButton UpdateButton { get; set; } = null!; protected override async Task OnInitializedAsync() { _module = (IJSInProcessObjectReference)await Js.InvokeAsync("import", "./Components/ErrorUi.razor.js"); UpdateSvc.UpdateStatusEvent += OnUpdateStatusChange; UpdateStatusSwitch(UpdateSvc.UpdateState); await CheckUpdate(); } private enum UpdateState { Unknown, Available, Installing, Installed, NoUpdate } private void OnUpdateStatusChange(object? _, UpdateService.UpdateStates newState) { UpdateStatusSwitch(newState); StateHasChanged(); } private void UpdateStatusSwitch(UpdateService.UpdateStates newState) { switch (newState) { case UpdateService.UpdateStates.UpdateInstalled: _updateState = UpdateState.Installed; break; case UpdateService.UpdateStates.UpdateInstalling: _updateState = UpdateState.Installing; UpdateButton.State = StateButton.StateEnum.Loading; break; case UpdateService.UpdateStates.UpdateAvailable: _updateState = UpdateState.Available; break; case UpdateService.UpdateStates.NoUpdate: _updateState = UpdateState.NoUpdate; UpdateButton.State = StateButton.StateEnum.Success; break; } } private async Task CheckUpdate() { try { await UpdateSvc.ServiceWorkerUpdateAsync(); } catch (Exception e) { Logger.LogError(e, "Failed to check for updates."); return; } _newVersion = UpdateSvc.BackendVersion; StateHasChanged(); } private async Task SkipWaiting() { var res = await UpdateSvc.ServiceWorkerSkipWaitingAsync(); if (!res) return; 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); } public void Dispose() { UpdateSvc.UpdateStatusEvent -= OnUpdateStatusChange; } }