improve reload in router to prevent looping

This commit is contained in:
sbwalker 2023-08-07 15:39:44 -04:00
parent e7b35bd0c2
commit 258f2dbe8f

View File

@ -126,7 +126,7 @@
}
else
{
NavigationManager.NavigateTo(_absoluteUri.Replace("?reload", ""), true);
NavigationManager.NavigateTo(_absoluteUri.Replace("?reload", "").Replace("&reload", ""), true);
return;
}
}
@ -184,12 +184,20 @@
// reload client application if server was restarted or site runtime/rendermode was modified
if (PageState != null && site != null && sync.SyncEvents.Exists(item => item.Action == SyncEventActions.Reload && ((item.EntityName == EntityNames.Host && site.Runtime != "Server") || (item.EntityName == EntityNames.Site && item.EntityId == site.SiteId))))
{
NavigationManager.NavigateTo(_absoluteUri, true);
if (!querystring.ContainsKey("reloaded"))
{
NavigationManager.NavigateTo(_absoluteUri + (!_absoluteUri.Contains("?") ? "?" : "&") + "reloaded", true);
return;
}
}
// reload client application if current user auth information has changed
if (PageState != null && user != null && sync.SyncEvents.Exists(item => item.Action == SyncEventActions.Reload && item.EntityName == EntityNames.User && item.EntityId == user.UserId))
{
NavigationManager.NavigateTo(_absoluteUri, true);
if (!querystring.ContainsKey("reloaded"))
{
NavigationManager.NavigateTo(_absoluteUri + (!_absoluteUri.Contains("?") ? "?" : "&") + "reloaded", true);
return;
}
}
// when site information has changed the PageState needs to be refreshed
if (sync.SyncEvents.Exists(item => item.EntityName == EntityNames.Site && item.EntityId == SiteState.Alias.SiteId))