[frontend/components] Add button to clear local storage on error UI

This commit is contained in:
Lilian 2025-03-20 20:02:59 +01:00
parent 6814488d30
commit f995810d19
No known key found for this signature in database

View file

@ -1,4 +1,5 @@
@using System.Text
@using Blazored.LocalStorage
@using Iceshrimp.Assets.PhosphorIcons
@using Iceshrimp.Frontend.Core.InMemoryLogger
@using Iceshrimp.Frontend.Core.Services
@ -9,6 +10,8 @@
@inject VersionService Version;
@inject InMemoryLogService LogService;
@inject IJSRuntime Js;
@inject ISyncLocalStorageService LocalStorage;
@inject SessionService Session;
<div class="error-ui">
<h3>@Loc["Unhandled Exception has occured"]</h3>
@ -53,6 +56,7 @@
</div>
<button class="button" @onclick="Reload"><Icon Name="Icons.ArrowsClockwise"/>@Loc["Reload Application"]</button>
<button class="button" @onclick="DownloadLogs"><Icon Name="Icons.DownloadSimple"/>@Loc["Download Logs"]</button>
<button class="button" @onclick="ClearStorage"><Icon Name="Icons.Warning"/>@Loc["Reset local data"]</button>
</div>
@ -78,4 +82,11 @@
var logBytes = LogService.GetLogs().SelectMany(p => Encoding.UTF8.GetBytes(p)).ToArray();
_module.InvokeVoid("DownloadFile", "log.txt", "text/plain", logBytes);
}
private void ClearStorage()
{
Session.EndSession();
LocalStorage.Clear();
Navigation.NavigateTo("/", true);
}
}