Don't initialize supervisor object for ingress

This commit is contained in:
Joakim Sørensen 2021-06-14 10:06:26 +00:00
parent 38640c99e3
commit ed6b54e5c6
3 changed files with 18 additions and 10 deletions

View File

@ -61,10 +61,11 @@ class HassioRouter extends HassRouterPage {
el.hass = this.hass;
el.narrow = this.narrow;
el.route = route;
el.supervisor = this.supervisor;
if (el.localName === "hassio-ingress-view") {
el.ingressPanel = this.panel.config && this.panel.config.ingress;
} else {
el.supervisor = this.supervisor;
}
}

View File

@ -21,7 +21,6 @@ import {
createHassioSession,
validateHassioSession,
} from "../../../src/data/hassio/ingress";
import { Supervisor } from "../../../src/data/supervisor/supervisor";
import { showAlertDialog } from "../../../src/dialogs/generic/show-dialog-box";
import "../../../src/layouts/hass-loading-screen";
import "../../../src/layouts/hass-subpage";
@ -31,11 +30,9 @@ import { HomeAssistant, Route } from "../../../src/types";
class HassioIngressView extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property({ attribute: false }) public supervisor!: Supervisor;
@property({ attribute: false }) public route!: Route;
@property() public route!: Route;
@property() public ingressPanel = false;
@property({ type: Boolean }) public ingressPanel = false;
@state() private _addon?: HassioAddonDetails;
@ -102,14 +99,14 @@ class HassioIngressView extends LitElement {
}
if (!addonInfo.version) {
await showAlertDialog(this, {
text: this.supervisor.localize("my.error_addon_not_installed"),
text: this.hass.localize("supervisor.my.error_addon_not_installed"),
title: addonInfo.name,
});
await nextRender();
navigate(`/hassio/addon/${addonInfo.slug}/info`, { replace: true });
} else if (!addonInfo.ingress) {
await showAlertDialog(this, {
text: this.supervisor.localize("my.error_addon_no_ingress"),
text: this.hass.localize("supervisor.my.error_addon_no_ingress"),
title: addonInfo.name,
});
await nextRender();

View File

@ -15,6 +15,7 @@ import {
fetchHassioHomeAssistantInfo,
fetchHassioInfo,
fetchHassioSupervisorInfo,
HassioPanelInfo,
} from "../../src/data/hassio/supervisor";
import { fetchSupervisorStore } from "../../src/data/supervisor/store";
import {
@ -25,7 +26,7 @@ import {
} from "../../src/data/supervisor/supervisor";
import { ProvideHassLitMixin } from "../../src/mixins/provide-hass-lit-mixin";
import { urlSyncMixin } from "../../src/state/url-sync-mixin";
import { HomeAssistant } from "../../src/types";
import { HomeAssistant, Route } from "../../src/types";
import { getTranslation } from "../../src/util/common-translation";
declare global {
@ -42,6 +43,10 @@ export class SupervisorBaseElement extends urlSyncMixin(
localize: () => "",
};
@property({ attribute: false }) public panel!: HassioPanelInfo;
@property({ attribute: false }) public route?: Route;
@state() private _unsubs: Record<string, UnsubscribeFunc> = {};
@state() private _collections: Record<string, Collection<unknown>> = {};
@ -110,7 +115,12 @@ export class SupervisorBaseElement extends urlSyncMixin(
this._language = this.hass.language;
}
this._initializeLocalize();
this._initSupervisor();
if (
!(this.panel.config && "ingress" in this.panel.config) &&
this.route?.path !== "/ingress"
) {
this._initSupervisor();
}
}
private async _initializeLocalize() {