Merge pull request #4053 from sbwalker/dev

optimize SiteRouter to only call SyncService for Interactive render mode
This commit is contained in:
Shaun Walker 2024-03-23 10:57:55 -04:00 committed by GitHub
commit 6e7ce10585
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -163,7 +163,9 @@
visitorId = PageState.VisitorId; visitorId = PageState.VisitorId;
} }
// process any sync events if (PageState.RenderMode == RenderModes.Interactive)
{
// process any sync events (for synchrozing the client application with the server)
var sync = await SyncService.GetSyncEventsAsync(lastsyncdate); var sync = await SyncService.GetSyncEventsAsync(lastsyncdate);
lastsyncdate = sync.SyncDate; lastsyncdate = sync.SyncDate;
if (sync.SyncEvents.Any()) if (sync.SyncEvents.Any())
@ -174,24 +176,13 @@
NavigationManager.NavigateTo(_absoluteUri, true); NavigationManager.NavigateTo(_absoluteUri, true);
return; return;
} }
// reload client application if site runtime/rendermode was modified
if (sync.SyncEvents.Exists(item => item.Action == SyncEventActions.Reload && item.EntityName == EntityNames.Site && item.EntityId == SiteState.Alias.SiteId))
{
NavigationManager.NavigateTo(_absoluteUri, true);
return;
}
// reload client application if current user auth information has changed
if (user != null && sync.SyncEvents.Exists(item => item.Action == SyncEventActions.Reload && item.EntityName == EntityNames.User && item.EntityId == user.UserId))
{
NavigationManager.NavigateTo(_absoluteUri, true);
return;
}
// refresh PageState when site information has changed // refresh PageState when site information has changed
if (sync.SyncEvents.Exists(item => item.Action == SyncEventActions.Refresh && item.EntityName == EntityNames.Site && item.EntityId == SiteState.Alias.SiteId)) if (sync.SyncEvents.Exists(item => item.Action == SyncEventActions.Refresh && item.EntityName == EntityNames.Site && item.EntityId == SiteState.Alias.SiteId))
{ {
refresh = true; refresh = true;
} }
} }
}
// get site // get site
if (PageState == null || refresh || PageState.Alias.SiteId != SiteState.Alias.SiteId) if (PageState == null || refresh || PageState.Alias.SiteId != SiteState.Alias.SiteId)