From 824f993694b895f4f09c6d7cb39cc838e395af56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Tue, 13 Jul 2021 00:52:03 +0200 Subject: [PATCH] Fix: Edge case where navigating through 2 different loaded panels caused incorrect width on posters --- dist/plex-meets-homeassistant.js | 10 +++++++++- src/plex-meets-homeassistant.ts | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index e83392c..c76dca0 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -20734,6 +20734,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { this.runBefore = ''; this.playTrailer = true; this.showExtras = true; + this.isVisible = true; this.showSearch = true; this.previousPageWidth = 0; this.runAfter = ''; @@ -20768,6 +20769,14 @@ class PlexMeetsHomeAssistant extends HTMLElement { } }; this.loadInitialData = async () => { + this.initialDataLoaded = true; + setInterval(() => { + const isVisibleNow = !lodash.isNull(this.offsetParent); + if (isVisibleNow && !this.isVisible) { + this.renderPage(); + } + this.isVisible = isVisibleNow; + }, 100); if (this.hassObj) { this.entityRegistry = await fetchEntityRegistry(this.hassObj.connection); } @@ -20834,7 +20843,6 @@ class PlexMeetsHomeAssistant extends HTMLElement { this.previousPageWidth = this.card.offsetWidth; } this.resizeBackground(); - this.initialDataLoaded = true; }; this.renderInitialData = async () => { let { entity } = JSON.parse(JSON.stringify(this.config)); diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index 0e0addf..16f12e3 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -45,6 +45,8 @@ class PlexMeetsHomeAssistant extends HTMLElement { showExtras = true; + isVisible = true; + showSearch = true; previousPageWidth = 0; @@ -159,6 +161,14 @@ class PlexMeetsHomeAssistant extends HTMLElement { }; loadInitialData = async (): Promise => { + this.initialDataLoaded = true; + setInterval(() => { + const isVisibleNow = !_.isNull(this.offsetParent); + if (isVisibleNow && !this.isVisible) { + this.renderPage(); + } + this.isVisible = isVisibleNow; + }, 100); if (this.hassObj) { this.entityRegistry = await fetchEntityRegistry(this.hassObj.connection); } @@ -228,7 +238,6 @@ class PlexMeetsHomeAssistant extends HTMLElement { this.previousPageWidth = this.card.offsetWidth; } this.resizeBackground(); - this.initialDataLoaded = true; }; renderInitialData = async (): Promise => {