From 9e0c4e7e08ea6f34fe785a9b86159b4a8be5c75d Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 11 Aug 2021 16:46:23 +0200 Subject: [PATCH] web/admin: fix version API being called too much Signed-off-by: Jens Langhammer --- web/src/interfaces/AdminInterface.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web/src/interfaces/AdminInterface.ts b/web/src/interfaces/AdminInterface.ts index ae4817208..9a39939b7 100644 --- a/web/src/interfaces/AdminInterface.ts +++ b/web/src/interfaces/AdminInterface.ts @@ -30,7 +30,7 @@ import { EVENT_SIDEBAR_TOGGLE, VERSION, } from "../constants"; -import { AdminApi } from "authentik-api"; +import { AdminApi, Version } from "authentik-api"; import { DEFAULT_CONFIG } from "../api/Config"; import { WebsocketClient } from "../common/ws"; @@ -47,6 +47,8 @@ export class AdminInterface extends LitElement { ws: WebsocketClient; + private version: Promise; + static get styles(): CSSResult[] { return [ PFBase, @@ -84,6 +86,7 @@ export class AdminInterface extends LitElement { window.addEventListener(EVENT_API_DRAWER_TOGGLE, () => { this.apiDrawerOpen = !this.apiDrawerOpen; }); + this.version = new AdminApi(DEFAULT_CONFIG).adminVersionRetrieve(); } render(): TemplateResult { @@ -138,7 +141,7 @@ export class AdminInterface extends LitElement { }; return html` ${until( - new AdminApi(DEFAULT_CONFIG).adminVersionRetrieve().then((version) => { + this.version.then((version) => { if (version.versionCurrent !== VERSION) { return html`