From fd9441dde2affd2097de8a0f8b1aa9034641d54c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Tue, 23 Feb 2021 16:16:24 +0100 Subject: [PATCH] Fix blank page in ingress when resizing window (#8439) --- hassio/src/hassio-router.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hassio/src/hassio-router.ts b/hassio/src/hassio-router.ts index 4118e82387..4e71ca7ca6 100644 --- a/hassio/src/hassio-router.ts +++ b/hassio/src/hassio-router.ts @@ -23,7 +23,7 @@ class HassioRouter extends HassRouterPage { protected routerOptions: RouterOptions = { // Hass.io has a page with tabs, so we route all non-matching routes to it. defaultPage: "dashboard", - initialLoad: () => this._fetchData(), + initialLoad: () => this._redirectIngress(), showLoading: true, routes: { dashboard: { @@ -50,7 +50,13 @@ class HassioRouter extends HassRouterPage { protected updatePageEl(el) { // the tabs page does its own routing so needs full route. - const route = el.nodeName === "HASSIO-PANEL" ? this.route : this.routeTail; + const hassioPanel = el.nodeName === "HASSIO-PANEL"; + const route = hassioPanel ? this.route : this.routeTail; + + if (hassioPanel && this.panel.config?.ingress) { + this._redirectIngress(); + return; + } el.hass = this.hass; el.narrow = this.narrow; @@ -63,15 +69,14 @@ class HassioRouter extends HassRouterPage { } } - private async _fetchData() { + private async _redirectIngress() { if (this.panel.config && this.panel.config.ingress) { - this._redirectIngress(this.panel.config.ingress); + this.route = { + prefix: "/hassio", + path: `/ingress/${this.panel.config.ingress}`, + }; } } - - private _redirectIngress(addonSlug: string) { - this.route = { prefix: "/hassio", path: `/ingress/${addonSlug}` }; - } } declare global {