if running on WebAssembly reload the client application if the server application is restarted
This commit is contained in:
parent
09c040128a
commit
bd48e1d8f1
|
@ -80,7 +80,7 @@
|
||||||
var urlparameters = string.Empty;
|
var urlparameters = string.Empty;
|
||||||
var editmode = false;
|
var editmode = false;
|
||||||
var reload = Reload.None;
|
var reload = Reload.None;
|
||||||
var lastsyncdate = DateTime.UtcNow;
|
var lastsyncdate = DateTime.UtcNow.AddHours(-1);
|
||||||
var runtime = GetRuntime();
|
var runtime = GetRuntime();
|
||||||
|
|
||||||
Uri uri = new Uri(_absoluteUri);
|
Uri uri = new Uri(_absoluteUri);
|
||||||
|
@ -107,9 +107,14 @@
|
||||||
SiteState.Alias = alias; // set state for services
|
SiteState.Alias = alias; // set state for services
|
||||||
lastsyncdate = alias.SyncDate;
|
lastsyncdate = alias.SyncDate;
|
||||||
|
|
||||||
// process any sync events for site
|
// process any sync events
|
||||||
if (reload != Reload.Site && alias.SyncEvents.Any())
|
if (reload != Reload.Site && alias.SyncEvents.Any())
|
||||||
{
|
{
|
||||||
|
// if running on WebAssembly reload the client application if the server application was restarted
|
||||||
|
if (runtime == Shared.Runtime.WebAssembly && PageState != null && alias.SyncEvents.Exists(item => item.TenantId == -1))
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo(uri.Scheme + "://" + uri.Authority + "?reload", true);
|
||||||
|
}
|
||||||
if (alias.SyncEvents.Exists(item => item.EntityName == EntityNames.Site && item.EntityId == alias.SiteId))
|
if (alias.SyncEvents.Exists(item => item.EntityName == EntityNames.Site && item.EntityId == alias.SiteId))
|
||||||
{
|
{
|
||||||
reload = Reload.Site;
|
reload = Reload.Site;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -17,7 +17,7 @@ namespace Oqtane.Infrastructure
|
||||||
|
|
||||||
public List<SyncEvent> GetSyncEvents(int tenantId, DateTime lastSyncDate)
|
public List<SyncEvent> GetSyncEvents(int tenantId, DateTime lastSyncDate)
|
||||||
{
|
{
|
||||||
return SyncEvents.Where(item => item.TenantId == tenantId && item.ModifiedOn >= lastSyncDate).ToList();
|
return SyncEvents.Where(item => (item.TenantId == tenantId || item.TenantId == -1) && item.ModifiedOn >= lastSyncDate).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddSyncEvent(int tenantId, string entityName, int entityId)
|
public void AddSyncEvent(int tenantId, string entityName, int entityId)
|
||||||
|
|
|
@ -226,7 +226,7 @@ namespace Oqtane
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISyncManager sync)
|
||||||
{
|
{
|
||||||
ServiceActivator.Configure(app.ApplicationServices);
|
ServiceActivator.Configure(app.ApplicationServices);
|
||||||
|
|
||||||
|
@ -264,6 +264,9 @@ namespace Oqtane
|
||||||
endpoints.MapControllers();
|
endpoints.MapControllers();
|
||||||
endpoints.MapFallbackToPage("/_Host");
|
endpoints.MapFallbackToPage("/_Host");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// create a sync event to identify server application startup
|
||||||
|
sync.AddSyncEvent(-1, "Application", -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user