improve PageState trimming

This commit is contained in:
sbwalker
2024-07-17 11:53:04 -04:00
parent 5610a14e49
commit b942a84b15
8 changed files with 16 additions and 46 deletions

View File

@ -6,21 +6,21 @@
{
@if (PageState.RenderMode == RenderModes.Interactive)
{
<ModuleActionsInteractive PageState="@_moduleActionsPageState" ModuleState="@ModuleState" />
<ModuleActionsInteractive PageState="@_pageState" ModuleState="@ModuleState" />
}
else
{
<ModuleActionsInteractive PageState="@_moduleActionsPageState" ModuleState="@ModuleState" @rendermode="@InteractiveRenderMode.GetInteractiveRenderMode(PageState.Site.Runtime, false)" />
<ModuleActionsInteractive PageState="@_pageState" ModuleState="@ModuleState" @rendermode="@InteractiveRenderMode.GetInteractiveRenderMode(PageState.Site.Runtime, false)" />
}
}
@code {
private ModuleActionsPageState _moduleActionsPageState;
private PageState _pageState;
protected override void OnParametersSet()
{
// trim PageState to mitigate page bloat caused by Blazor serializing/encrypting state when crossing render mode boundaries
_moduleActionsPageState = new ModuleActionsPageState
_pageState = new PageState
{
Alias = PageState.Alias,
Page = PageState.Page,

View File

@ -9,6 +9,7 @@ using Oqtane.Services;
using Oqtane.Shared;
using System.Net;
using Microsoft.Extensions.Localization;
using Oqtane.UI;
// ReSharper disable UnassignedGetOnlyAutoProperty
// ReSharper disable MemberCanBePrivate.Global
@ -22,7 +23,7 @@ namespace Oqtane.Themes.Controls
[Inject] public IModuleService ModuleService { get; set; }
[Inject] public IStringLocalizer<ModuleActionsBase> Localizer { get; set; }
[Parameter] public ModuleActionsPageState PageState { get; set; }
[Parameter] public PageState PageState { get; set; }
[Parameter] public Module ModuleState { get; set; }
public List<ActionViewModel> Actions;

View File

@ -1,12 +0,0 @@
using Oqtane.Models;
namespace Oqtane.Themes.Controls
{
public class ModuleActionsPageState
{
public Alias Alias { get; set; }
public Page Page { get; set; }
public User User { get; set; }
public bool EditMode { get; set; }
}
}