From c469a619085e6e7c2c89e0aac618d2a35e4004b2 Mon Sep 17 00:00:00 2001 From: sbwalker Date: Sat, 16 Mar 2024 16:24:12 -0400 Subject: [PATCH] optimize to remove IsInstalled API call on every Web UI request (MAUI clients still require this logic) --- Oqtane.Client/UI/Routes.razor | 53 +++++++++++++++++------------------ 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/Oqtane.Client/UI/Routes.razor b/Oqtane.Client/UI/Routes.razor index 4cf99119..b998003a 100644 --- a/Oqtane.Client/UI/Routes.razor +++ b/Oqtane.Client/UI/Routes.razor @@ -8,33 +8,24 @@ @if (_initialized) { - @if (!_installation.Success) + @if (!_installed) { } else { - @if (string.IsNullOrEmpty(_installation.Message)) + if (RenderMode == RenderModes.Static) { - if (PageState?.RenderMode == RenderModes.Static) - { - - - - } - else - { -
- - - -
- } + + + } else { -
- @_installation.Message +
+ + +
} } @@ -63,28 +54,36 @@ HttpContext HttpContext { get; set; } private bool _initialized = false; + private bool _installed = false; private string _display = "display: none;"; - private Installation _installation = new Installation { Success = false, Message = "" }; private PageState _pageState { get; set; } protected override async Task OnParametersSetAsync() { - if (PageState != null) - { - _pageState = PageState; - } - SiteState.AntiForgeryToken = AntiForgeryToken; SiteState.AuthorizationToken = AuthorizationToken; SiteState.RemoteIPAddress = (_pageState != null) ? _pageState.RemoteIPAddress : ""; SiteState.Platform = Platform; SiteState.IsPrerendering = (HttpContext != null) ? true : false; - _installation = await InstallationService.IsInstalled(); - if (_installation.Alias != null) + if (Runtime == Runtimes.Hybrid) { - SiteState.Alias = _installation.Alias; + var installation = await InstallationService.IsInstalled(); + _installed = installation.Success; + if (installation.Alias != null) + { + SiteState.Alias = installation.Alias; + } + } + else + { + if (PageState != null) + { + _pageState = PageState; + SiteState.Alias = PageState.Alias; + _installed = true; + } } _initialized = true; }