From 258f2dbe8fc931a479587e03eb32dc3c758c4975 Mon Sep 17 00:00:00 2001 From: sbwalker Date: Mon, 7 Aug 2023 15:39:44 -0400 Subject: [PATCH] improve reload in router to prevent looping --- Oqtane.Client/UI/SiteRouter.razor | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Oqtane.Client/UI/SiteRouter.razor b/Oqtane.Client/UI/SiteRouter.razor index 892a89d1..c2a61f64 100644 --- a/Oqtane.Client/UI/SiteRouter.razor +++ b/Oqtane.Client/UI/SiteRouter.razor @@ -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))