Add shared recent tables state

This commit is contained in:
2026-03-21 13:53:56 +01:00
parent 8b2984e7bd
commit 40b01d707f
6 changed files with 139 additions and 1 deletions

View File

@@ -6,6 +6,7 @@
@using System.Linq
@inject IJSRuntime JSRuntime
@inject LookupService LookupService
@inject RolemasterDb.App.Frontend.AppState.RecentTablesState RecentTablesState
<PageTitle>Critical Tables</PageTitle>
@@ -292,7 +293,10 @@
if (tableDetail is null)
{
detailError = "The selected table could not be loaded.";
return;
}
await RecordRecentTableVisitAsync();
}
catch (Exception exception)
{
@@ -769,6 +773,20 @@
private Task PersistSelectedTableAsync(string tableSlug) =>
JSRuntime.InvokeVoidAsync("localStorage.setItem", SelectedTableStorageKey, tableSlug).AsTask();
private Task RecordRecentTableVisitAsync()
{
if (SelectedTableReference is not { } selectedTable)
{
return Task.CompletedTask;
}
return RecentTablesState.RecordVisitAsync(
selectedTable.Key,
selectedTable.Label,
selectedTable.Family,
selectedTable.CurationPercentage);
}
private string GetTableOptionCssClass(CriticalTableReference table)
{
var classes = new List<string>();