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 => {