improved rendering optimization
This commit is contained in:
parent
3dc28c7291
commit
02c22c1894
|
@ -21,7 +21,7 @@
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (PageState.RenderModuleInstance(ModuleState))
|
if (ShouldRender())
|
||||||
{
|
{
|
||||||
var htmltext = await HtmlTextService.GetHtmlTextAsync(ModuleState.ModuleId);
|
var htmltext = await HtmlTextService.GetHtmlTextAsync(ModuleState.ModuleId);
|
||||||
if (htmltext != null)
|
if (htmltext != null)
|
||||||
|
|
|
@ -113,6 +113,11 @@ namespace Oqtane.Modules
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool ShouldRender()
|
||||||
|
{
|
||||||
|
return PageState.RenderId == ModuleState.RenderId;
|
||||||
|
}
|
||||||
|
|
||||||
// path method
|
// path method
|
||||||
|
|
||||||
public string ModulePath()
|
public string ModulePath()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
|
|
||||||
namespace Oqtane.Themes
|
namespace Oqtane.Themes
|
||||||
|
@ -8,5 +8,9 @@ namespace Oqtane.Themes
|
||||||
[CascadingParameter]
|
[CascadingParameter]
|
||||||
protected Module ModuleState { get; set; }
|
protected Module ModuleState { get; set; }
|
||||||
|
|
||||||
|
protected override bool ShouldRender()
|
||||||
|
{
|
||||||
|
return PageState.RenderId == ModuleState.RenderId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,11 @@
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public Module ModuleState { get; set; }
|
public Module ModuleState { get; set; }
|
||||||
|
|
||||||
|
protected override bool ShouldRender()
|
||||||
|
{
|
||||||
|
return PageState.RenderId == ModuleState.RenderId;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
((INotifyPropertyChanged)SiteState.Properties).PropertyChanged += PropertyChanged;
|
((INotifyPropertyChanged)SiteState.Properties).PropertyChanged += PropertyChanged;
|
||||||
|
@ -52,7 +57,7 @@
|
||||||
_useadminborder = false;
|
_useadminborder = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PageState.RenderModuleInstance(ModuleState))
|
if (ShouldRender())
|
||||||
{
|
{
|
||||||
ComponentType = Type.GetType(container) ?? Type.GetType(Constants.DefaultContainer);
|
ComponentType = Type.GetType(container) ?? Type.GetType(Constants.DefaultContainer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,10 +48,15 @@ else
|
||||||
|
|
||||||
private ModuleMessage ModuleMessage { get; set; }
|
private ModuleMessage ModuleMessage { get; set; }
|
||||||
|
|
||||||
|
protected override bool ShouldRender()
|
||||||
|
{
|
||||||
|
return PageState.RenderId == ModuleState.RenderId;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnParametersSet()
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
_message = "";
|
_message = "";
|
||||||
if (PageState.RenderModuleInstance(ModuleState))
|
if (ShouldRender())
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(ModuleState.ModuleType))
|
if (!string.IsNullOrEmpty(ModuleState.ModuleType))
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace Oqtane.UI
|
||||||
public string RemoteIPAddress { get; set; }
|
public string RemoteIPAddress { get; set; }
|
||||||
public string ReturnUrl { get; set; }
|
public string ReturnUrl { get; set; }
|
||||||
public bool IsInternalNavigation { get; set; }
|
public bool IsInternalNavigation { get; set; }
|
||||||
|
public Guid RenderId { get; set; }
|
||||||
|
|
||||||
public List<Page> Pages
|
public List<Page> Pages
|
||||||
{
|
{
|
||||||
|
@ -36,12 +37,5 @@ namespace Oqtane.UI
|
||||||
{
|
{
|
||||||
get { return Site.Languages; }
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,9 @@ else
|
||||||
{
|
{
|
||||||
foreach (Module module in PageState.Modules.Where(item => item.PageId == PageState.Page.PageId))
|
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;
|
var pane = module.Pane;
|
||||||
if (module.ModuleId == PageState.ModuleId && PageState.Action != Constants.DefaultAction)
|
if (module.ModuleId == PageState.ModuleId && PageState.Action != Constants.DefaultAction)
|
||||||
{
|
{
|
||||||
|
|
|
@ -289,7 +289,8 @@
|
||||||
VisitorId = VisitorId,
|
VisitorId = VisitorId,
|
||||||
RemoteIPAddress = SiteState.RemoteIPAddress,
|
RemoteIPAddress = SiteState.RemoteIPAddress,
|
||||||
ReturnUrl = returnurl,
|
ReturnUrl = returnurl,
|
||||||
IsInternalNavigation = _isInternalNavigation
|
IsInternalNavigation = _isInternalNavigation,
|
||||||
|
RenderId = Guid.NewGuid()
|
||||||
};
|
};
|
||||||
|
|
||||||
OnStateChange?.Invoke(_pagestate);
|
OnStateChange?.Invoke(_pagestate);
|
||||||
|
@ -508,7 +509,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
module.PaneModuleIndex = paneindex[module.Pane.ToLower()];
|
module.PaneModuleIndex = paneindex[module.Pane.ToLower()];
|
||||||
module.Action = action;
|
|
||||||
|
|
||||||
// container fallback
|
// container fallback
|
||||||
if (string.IsNullOrEmpty(module.ContainerType))
|
if (string.IsNullOrEmpty(module.ContainerType))
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace Oqtane.Models
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public int PaneModuleCount { get; set; }
|
public int PaneModuleCount { get; set; }
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public string Action { get; set; }
|
public Guid RenderId { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user