Skip to content

Commit

Permalink
Merge pull request #3751 from sbwalker/dev
Browse files Browse the repository at this point in the history
specify default interactive render mode
  • Loading branch information
sbwalker authored Feb 9, 2024
2 parents 7c3cb11 + f6fb3cc commit bda5619
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions Oqtane.Client/UI/ModuleInstance.razor
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
@namespace Oqtane.UI
@inject SiteState SiteState

<div>Render Mode: @ModuleState.RenderMode</div><br />
@if (PageState.Site.RenderMode == RenderModes.Interactive || ModuleState.RenderMode == RenderModes.Static)
{
<div>Render Mode: @PageState.Site.RenderMode</div><br />
<RenderModeBoundary ModuleState="@ModuleState" PageState="@PageState" SiteState="@SiteState" />
}
else
{
<RenderModeBoundary ModuleState="@ModuleState" PageState="@PageState" SiteState="@SiteState" @rendermode="@RenderMode.GetInteractiveRenderMode(PageState.Site.Runtime, PageState.Site.Prerender)" />
<div>Render Mode: @ModuleState.RenderMode</div><br />
<RenderModeBoundary ModuleState="@ModuleState" PageState="@PageState" SiteState="@SiteState" @rendermode="@RenderMode.GetInteractiveRenderMode(PageState.Site.Runtime, PageState.Site.Prerender)" />
}

@code {
Expand Down
2 changes: 1 addition & 1 deletion Oqtane.Client/UI/RenderMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static IComponentRenderMode GetInteractiveRenderMode(string runtime, bool
case Runtimes.Auto:
return new InteractiveAutoRenderMode(prerender);
}
return null;
return new InteractiveServerRenderMode(prerender); // default to interactiver server
}
}
}
12 changes: 6 additions & 6 deletions Oqtane.Client/UI/RenderModeBoundary.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@namespace Oqtane.UI
@inject SiteState SiteStateService
@inject SiteState ComponentSiteState // can refer to either a static or interactive SiteState - it depends on the render mode
@inject IStringLocalizer<ModuleInstance> Localizer
@inject ILogService LoggingService
@inherits ErrorBoundary
Expand Down Expand Up @@ -71,11 +71,11 @@ else
if (ModuleType != null)
{
// repopulate the SiteState service based on the values passed in the SiteState parameter (this is how state is marshalled across the render mode boundary)
SiteStateService.Alias = SiteState.Alias;
SiteStateService.AntiForgeryToken = SiteState.AntiForgeryToken;
SiteStateService.AuthorizationToken = SiteState.AuthorizationToken;
SiteStateService.RemoteIPAddress = SiteState.RemoteIPAddress;
SiteStateService.IsPrerendering = SiteState.IsPrerendering;
ComponentSiteState.Alias = SiteState.Alias;
ComponentSiteState.AntiForgeryToken = SiteState.AntiForgeryToken;
ComponentSiteState.AuthorizationToken = SiteState.AuthorizationToken;
ComponentSiteState.RemoteIPAddress = SiteState.RemoteIPAddress;
ComponentSiteState.IsPrerendering = SiteState.IsPrerendering;

ModuleParameters = new Dictionary<string, object> { { "RenderModeBoundary", this } };
}
Expand Down

0 comments on commit bda5619

Please sign in to comment.