refactor: finish route-first shell
This commit is contained in:
@@ -14,34 +14,6 @@ public partial class Workspace : IAsyncDisposable
|
||||
State.IsScreenMenuOpen = false;
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
State.HasInteractiveRenderStarted = true;
|
||||
if (firstRender)
|
||||
{
|
||||
await Session.InitializeAsync();
|
||||
HasSessionInitialized = true;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!HasSessionInitialized)
|
||||
return;
|
||||
|
||||
if (!EnableCharacterControls)
|
||||
{
|
||||
EnableCharacterControls = true;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
return;
|
||||
}
|
||||
|
||||
if (EnableCustomRollComposer)
|
||||
return;
|
||||
|
||||
EnableCustomRollComposer = true;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
[JSInvokable]
|
||||
public Task OnStateEventReceived(CampaignStateSnapshot state)
|
||||
{
|
||||
@@ -126,6 +98,22 @@ public partial class Workspace : IAsyncDisposable
|
||||
return InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private Task InitializeRouteAsync()
|
||||
{
|
||||
return InitializationTask ??= InitializeRouteCoreAsync();
|
||||
}
|
||||
|
||||
private async Task InitializeRouteCoreAsync()
|
||||
{
|
||||
if (HasSessionInitialized)
|
||||
return;
|
||||
|
||||
State.HasInteractiveRenderStarted = true;
|
||||
await Session.InitializeAsync();
|
||||
HasSessionInitialized = true;
|
||||
await RequestRefreshAsync();
|
||||
}
|
||||
|
||||
private static bool IsStaticRenderInteropException(InvalidOperationException exception)
|
||||
{
|
||||
return exception.Message.Contains("statically rendered", StringComparison.OrdinalIgnoreCase);
|
||||
@@ -145,16 +133,14 @@ public partial class Workspace : IAsyncDisposable
|
||||
|
||||
private WorkspaceState State { get; } = new();
|
||||
private bool HasSessionInitialized { get; set; }
|
||||
private bool EnableCharacterControls { get; set; }
|
||||
private bool EnableCustomRollComposer { get; set; }
|
||||
private bool IsPlayRoute => Route == WorkspaceRoute.Play;
|
||||
private bool IsCampaignsRoute => Route == WorkspaceRoute.Campaigns;
|
||||
private bool IsAdminRoute => Route == WorkspaceRoute.Admin;
|
||||
private string AppCssClass => IsPlayRoute ? "rr-app app-play" : "rr-app";
|
||||
|
||||
private WorkspacePageContext PageContext => new(State, Play, Campaigns, Admin, Scope, Session,
|
||||
RequestRefreshAsync, EnableCharacterControls, EnableCustomRollComposer, AdminDatabaseDownloadUrl,
|
||||
HeaderMenuItems, IsPlayRoute, IsCampaignsRoute, IsAdminRoute);
|
||||
InitializeRouteAsync, HasSessionInitialized, RequestRefreshAsync, AdminDatabaseDownloadUrl, HeaderMenuItems,
|
||||
IsPlayRoute, IsCampaignsRoute, IsAdminRoute);
|
||||
|
||||
private WorkspaceCampaignScopeCoordinator Scope => m_Scope ??= new(State, Feedback, JS, WorkspaceQuery,
|
||||
() => IsPlayRoute, Play.EnsureSelectedCharacterActiveAsync, Play.RefreshSelectedCharacterSheetAsync,
|
||||
@@ -231,4 +217,5 @@ public partial class Workspace : IAsyncDisposable
|
||||
|
||||
private WorkspaceCampaignScopeCoordinator? m_Scope;
|
||||
private WorkspaceSessionCoordinator? m_Session;
|
||||
private Task? InitializationTask { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user