Merge pull request #3614 from sbwalker/dev

improved rendering optimization
This commit is contained in:
Shaun Walker 2024-01-05 11:53:57 -05:00 committed by GitHub
commit cd3493e040
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 30 additions and 14 deletions

View File

@ -21,7 +21,7 @@
{
try
{
if (PageState.RenderModuleInstance(ModuleState))
if (ShouldRender())
{
var htmltext = await HtmlTextService.GetHtmlTextAsync(ModuleState.ModuleId);
if (htmltext != null)

View File

@ -113,6 +113,11 @@ namespace Oqtane.Modules
}
}
protected override bool ShouldRender()
{
return PageState.RenderId == ModuleState.RenderId;
}
// path method
public string ModulePath()

View File

@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components;
using Oqtane.Models;
namespace Oqtane.Themes
@ -8,5 +8,9 @@ namespace Oqtane.Themes
[CascadingParameter]
protected Module ModuleState { get; set; }
protected override bool ShouldRender()
{
return PageState.RenderId == ModuleState.RenderId;
}
}
}

View File

@ -30,6 +30,11 @@
[Parameter]
public Module ModuleState { get; set; }
protected override bool ShouldRender()
{
return PageState.RenderId == ModuleState.RenderId;
}
protected override void OnInitialized()
{
((INotifyPropertyChanged)SiteState.Properties).PropertyChanged += PropertyChanged;
@ -52,7 +57,7 @@
_useadminborder = false;
}
if (PageState.RenderModuleInstance(ModuleState))
if (ShouldRender())
{
ComponentType = Type.GetType(container) ?? Type.GetType(Constants.DefaultContainer);
}

View File

@ -48,10 +48,15 @@ else
private ModuleMessage ModuleMessage { get; set; }
protected override bool ShouldRender()
{
return PageState.RenderId == ModuleState.RenderId;
}
protected override void OnParametersSet()
{
_message = "";
if (PageState.RenderModuleInstance(ModuleState))
if (ShouldRender())
{
if (!string.IsNullOrEmpty(ModuleState.ModuleType))
{

View File

@ -23,6 +23,7 @@ namespace Oqtane.UI
public string RemoteIPAddress { get; set; }
public string ReturnUrl { get; set; }
public bool IsInternalNavigation { get; set; }
public Guid RenderId { get; set; }
public List<Page> Pages
{
@ -36,12 +37,5 @@ namespace Oqtane.UI
{
get { return Site.Languages; }
}
// determines if the PageState matches the ModuleState for component rendering purposes
public bool RenderModuleInstance(Module ModuleState)
{
return Page.PageId == ModuleState.PageId && (ModuleId == -1 || ModuleId == ModuleState.ModuleId) && Action == ModuleState.Action;
}
}
}

View File

@ -45,6 +45,9 @@ else
{
foreach (Module module in PageState.Modules.Where(item => item.PageId == PageState.Page.PageId))
{
// set renderid - this allows the framework to determine which components should be rendered when PageState changes
module.RenderId = PageState.RenderId;
var pane = module.Pane;
if (module.ModuleId == PageState.ModuleId && PageState.Action != Constants.DefaultAction)
{

View File

@ -289,7 +289,8 @@
VisitorId = VisitorId,
RemoteIPAddress = SiteState.RemoteIPAddress,
ReturnUrl = returnurl,
IsInternalNavigation = _isInternalNavigation
IsInternalNavigation = _isInternalNavigation,
RenderId = Guid.NewGuid()
};
OnStateChange?.Invoke(_pagestate);
@ -508,7 +509,6 @@
}
module.PaneModuleIndex = paneindex[module.Pane.ToLower()];
module.Action = action;
// container fallback
if (string.IsNullOrEmpty(module.ContainerType))

View File

@ -86,7 +86,7 @@ namespace Oqtane.Models
[NotMapped]
public int PaneModuleCount { get; set; }
[NotMapped]
public string Action { get; set; }
public Guid RenderId { get; set; }
#endregion