fix: phase authenticated startup

This commit is contained in:
2026-05-04 23:02:39 +02:00
parent f86ac43153
commit 56e0ec1e79
10 changed files with 312 additions and 163 deletions

View File

@@ -31,8 +31,12 @@ public partial class Workspace : IAsyncDisposable
{
RenderCount += 1;
Logger.LogInformation(
"Workspace.OnAfterRenderAsync route={Route} renderCount={RenderCount} firstRender={FirstRender} hasSessionInitialized={HasSessionInitialized} state=[{State}]",
Route, RenderCount, firstRender, HasSessionInitialized, WorkspaceDiagnosticSummary.DescribeState(State));
"Workspace.OnAfterRenderAsync route={Route} renderCount={RenderCount} firstRender={FirstRender} renderPhase={RenderPhase} hasSessionInitialized={HasSessionInitialized} state=[{State}]",
Route, RenderCount, firstRender, RenderPhase, HasSessionInitialized,
WorkspaceDiagnosticSummary.DescribeState(State));
if (RenderPhase < WorkspaceRenderPhase.RouteSkeleton)
return AdvanceRenderPhaseAsync("Workspace.OnAfterRenderAsync");
return Task.CompletedTask;
}
@@ -149,6 +153,14 @@ public partial class Workspace : IAsyncDisposable
return InitializationTask ??= InitializeRouteCoreAsync();
}
private Task EnsureLiveRenderPhaseAsync()
{
if (RenderPhase == WorkspaceRenderPhase.Live)
return Task.CompletedTask;
return AdvanceRenderPhaseAsync("WorkspaceRouteView.EnsureLiveRenderPhaseAsync", WorkspaceRenderPhase.Live);
}
private async Task InitializeRouteCoreAsync()
{
if (HasSessionInitialized)
@@ -199,6 +211,19 @@ public partial class Workspace : IAsyncDisposable
return exception.Message.Contains("statically rendered", StringComparison.OrdinalIgnoreCase);
}
private Task AdvanceRenderPhaseAsync(string source, WorkspaceRenderPhase? targetPhase = null)
{
var nextPhase = targetPhase ?? (WorkspaceRenderPhase)((int)RenderPhase + 1);
if (nextPhase <= RenderPhase)
return Task.CompletedTask;
Logger.LogInformation(
"Workspace.AdvanceRenderPhaseAsync source={Source} route={Route} from={FromPhase} to={ToPhase}",
source, Route, RenderPhase, nextPhase);
RenderPhase = nextPhase;
return RequestRefreshAsync(source);
}
[Inject] private IJSRuntime JS { get; set; } = null!;
[Inject] private RpgRollerApiClient ApiClient { get; set; } = null!;
@@ -223,8 +248,8 @@ public partial class Workspace : IAsyncDisposable
private bool ShowConnectionStateInHeader => IsPlayRoute;
private WorkspacePageContext PageContext => new(State, Play, Campaigns, Admin, Scope, Session,
InitializeRouteAsync, HasSessionInitialized, RequestRefreshAsync, AdminDatabaseDownloadUrl, HeaderMenuItems,
IsPlayRoute, IsCampaignsRoute, IsAdminRoute);
InitializeRouteAsync, HasSessionInitialized, RequestRefreshAsync, EnsureLiveRenderPhaseAsync,
AdminDatabaseDownloadUrl, HeaderMenuItems, RenderPhase, IsPlayRoute, IsCampaignsRoute, IsAdminRoute);
private WorkspaceCampaignScopeCoordinator Scope => m_Scope ??= new(State, Feedback, JS, WorkspaceQuery,
() => IsPlayRoute, Play.EnsureSelectedCharacterActiveAsync, Play.RefreshSelectedCharacterSheetAsync,
@@ -308,4 +333,5 @@ public partial class Workspace : IAsyncDisposable
private Task? InitializationTask { get; set; }
private WorkspaceRoute? PreviousRoute { get; set; }
private int RenderCount { get; set; }
private WorkspaceRenderPhase RenderPhase { get; set; }
}