Revert "Fixed first render js bug"

This commit is contained in:
Shaun Walker 2022-01-12 14:07:50 -05:00 committed by GitHub
parent cfe8059176
commit dda71e5ccd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,19 +46,22 @@ namespace Oqtane.Modules
// base lifecycle method for handling JSInterop script registration
protected override async Task OnInitializedAsync()
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (Resources != null && Resources.Exists(item => item.ResourceType == ResourceType.Script))
if (firstRender)
{
var scripts = new List<object>();
foreach (Resource resource in Resources.Where(item => item.ResourceType == ResourceType.Script && item.Declaration != ResourceDeclaration.Global))
if (Resources != null && Resources.Exists(item => item.ResourceType == ResourceType.Script))
{
scripts.Add(new { href = resource.Url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "" });
}
if (scripts.Any())
{
var interop = new Interop(JSRuntime);
await interop.IncludeScripts(scripts.ToArray());
var scripts = new List<object>();
foreach (Resource resource in Resources.Where(item => item.ResourceType == ResourceType.Script && item.Declaration != ResourceDeclaration.Global))
{
scripts.Add(new { href = resource.Url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "" });
}
if (scripts.Any())
{
var interop = new Interop(JSRuntime);
await interop.IncludeScripts(scripts.ToArray());
}
}
}
}