improve PageState trimming
This commit is contained in:
parent
5610a14e49
commit
b942a84b15
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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; }
|
||||
}
|
||||
}
|
|
@ -32,11 +32,11 @@
|
|||
{
|
||||
@if (PageState.RenderMode == RenderModes.Interactive)
|
||||
{
|
||||
<ControlPanelInteractive PageState="@_controlPanelPageState" SiteState="@SiteState" ButtonClass="@ButtonClass" ContainerClass="@ContainerClass" HeaderClass="@HeaderClass" BodyClass="@BodyClass" ShowLanguageSwitcher="@ShowLanguageSwitcher" LanguageDropdownAlignment="@LanguageDropdownAlignment" CanViewAdminDashboard="@_canViewAdminDashboard" />
|
||||
<ControlPanelInteractive PageState="@_pageState" SiteState="@SiteState" ButtonClass="@ButtonClass" ContainerClass="@ContainerClass" HeaderClass="@HeaderClass" BodyClass="@BodyClass" ShowLanguageSwitcher="@ShowLanguageSwitcher" LanguageDropdownAlignment="@LanguageDropdownAlignment" CanViewAdminDashboard="@_canViewAdminDashboard" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<ControlPanelInteractive PageState="@_controlPanelPageState" SiteState="@SiteState" ButtonClass="@ButtonClass" ContainerClass="@ContainerClass" HeaderClass="@HeaderClass" BodyClass="@BodyClass" ShowLanguageSwitcher="@ShowLanguageSwitcher" LanguageDropdownAlignment="@LanguageDropdownAlignment" CanViewAdminDashboard="@_canViewAdminDashboard" @rendermode="@InteractiveRenderMode.GetInteractiveRenderMode(PageState.Site.Runtime, false)" />
|
||||
<ControlPanelInteractive PageState="@_pageState" SiteState="@SiteState" ButtonClass="@ButtonClass" ContainerClass="@ContainerClass" HeaderClass="@HeaderClass" BodyClass="@BodyClass" ShowLanguageSwitcher="@ShowLanguageSwitcher" LanguageDropdownAlignment="@LanguageDropdownAlignment" CanViewAdminDashboard="@_canViewAdminDashboard" @rendermode="@InteractiveRenderMode.GetInteractiveRenderMode(PageState.Site.Runtime, false)" />
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@
|
|||
[Parameter]
|
||||
public string LanguageDropdownAlignment { get; set; } = string.Empty; // Empty or Left or Right
|
||||
|
||||
private ControlPanelPageState _controlPanelPageState;
|
||||
private PageState _pageState;
|
||||
private bool _canViewAdminDashboard = false;
|
||||
private bool _showEditMode = false;
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
|||
}
|
||||
|
||||
// trim PageState to mitigate page bloat caused by Blazor serializing/encrypting state when crossing render mode boundaries
|
||||
_controlPanelPageState = new ControlPanelPageState
|
||||
_pageState = new PageState
|
||||
{
|
||||
Alias = PageState.Alias,
|
||||
Site = new Site
|
||||
|
|
|
@ -228,7 +228,7 @@
|
|||
public SiteState SiteState { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public ControlPanelPageState PageState { get; set; }
|
||||
public PageState PageState { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string ButtonClass { get; set; }
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.UI;
|
||||
|
||||
namespace Oqtane.Themes.Controls
|
||||
{
|
||||
public class ControlPanelPageState
|
||||
{
|
||||
public Alias Alias { get; set; }
|
||||
public Site Site { get; set; }
|
||||
public Page Page { get; set; }
|
||||
public User User { get; set; }
|
||||
public Uri Uri { get; set; }
|
||||
public Route Route { get; set; }
|
||||
public string RenderMode { get; set; }
|
||||
public Shared.Runtime Runtime { get; set; }
|
||||
}
|
||||
}
|
|
@ -43,7 +43,7 @@
|
|||
{
|
||||
// trim PageState to mitigate page bloat caused by Blazor serializing/encrypting state when crossing render mode boundaries
|
||||
// please note that this performance optimization results in the PageState.Pages property not being available for use in Interactive components
|
||||
PageState.Site.Pages = new List<Page>();
|
||||
PageState.Site.Pages = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,11 +30,11 @@ namespace Oqtane.UI
|
|||
|
||||
public List<Page> Pages
|
||||
{
|
||||
get { return Site.Pages; }
|
||||
get { return Site?.Pages; }
|
||||
}
|
||||
public List<Language> Languages
|
||||
{
|
||||
get { return Site.Languages; }
|
||||
get { return Site?.Languages; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user