web/admin: fix version API being called too much
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
7e62b82d56
commit
9e0c4e7e08
|
@ -30,7 +30,7 @@ import {
|
||||||
EVENT_SIDEBAR_TOGGLE,
|
EVENT_SIDEBAR_TOGGLE,
|
||||||
VERSION,
|
VERSION,
|
||||||
} from "../constants";
|
} from "../constants";
|
||||||
import { AdminApi } from "authentik-api";
|
import { AdminApi, Version } from "authentik-api";
|
||||||
import { DEFAULT_CONFIG } from "../api/Config";
|
import { DEFAULT_CONFIG } from "../api/Config";
|
||||||
import { WebsocketClient } from "../common/ws";
|
import { WebsocketClient } from "../common/ws";
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@ export class AdminInterface extends LitElement {
|
||||||
|
|
||||||
ws: WebsocketClient;
|
ws: WebsocketClient;
|
||||||
|
|
||||||
|
private version: Promise<Version>;
|
||||||
|
|
||||||
static get styles(): CSSResult[] {
|
static get styles(): CSSResult[] {
|
||||||
return [
|
return [
|
||||||
PFBase,
|
PFBase,
|
||||||
|
@ -84,6 +86,7 @@ export class AdminInterface extends LitElement {
|
||||||
window.addEventListener(EVENT_API_DRAWER_TOGGLE, () => {
|
window.addEventListener(EVENT_API_DRAWER_TOGGLE, () => {
|
||||||
this.apiDrawerOpen = !this.apiDrawerOpen;
|
this.apiDrawerOpen = !this.apiDrawerOpen;
|
||||||
});
|
});
|
||||||
|
this.version = new AdminApi(DEFAULT_CONFIG).adminVersionRetrieve();
|
||||||
}
|
}
|
||||||
|
|
||||||
render(): TemplateResult {
|
render(): TemplateResult {
|
||||||
|
@ -138,7 +141,7 @@ export class AdminInterface extends LitElement {
|
||||||
};
|
};
|
||||||
return html`
|
return html`
|
||||||
${until(
|
${until(
|
||||||
new AdminApi(DEFAULT_CONFIG).adminVersionRetrieve().then((version) => {
|
this.version.then((version) => {
|
||||||
if (version.versionCurrent !== VERSION) {
|
if (version.versionCurrent !== VERSION) {
|
||||||
return html`<ak-sidebar-item ?highlight=${true}>
|
return html`<ak-sidebar-item ?highlight=${true}>
|
||||||
<span slot="label"
|
<span slot="label"
|
||||||
|
|
Reference in a new issue