From f0ab57ba37c284af36cf14b237826e33b06350f7 Mon Sep 17 00:00:00 2001 From: Cloos <36499953+Clooos@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:14:41 +0100 Subject: [PATCH] v1.5.3 --- src/bubble-card.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/bubble-card.js b/src/bubble-card.js index 0178182..cfbc6fd 100644 --- a/src/bubble-card.js +++ b/src/bubble-card.js @@ -1,9 +1,22 @@ -var version = 'v1.5.2'; +var version = 'v1.5.3'; let editor; let entityStates = {}; let lastCall = { entityId: null, stateChanged: null, timestamp: null }; +// Check if bubble-pop-up.js is installed as a resource and remove it (fix for the previous 1.5.0/1 users) +async function addResource(hass) { + let resources = await hass.callWS({ type: "lovelace/resources" }); + let resource = resources.find(r => r.url.includes("bubble-pop-up.js")); + + if (resource) { + await hass.callWS({ + type: "lovelace/resources/delete", + resource_id: resource.id + }); + } +} + class BubbleCard extends HTMLElement { constructor() { super(); @@ -50,6 +63,13 @@ class BubbleCard extends HTMLElement { } set hass(hass) { + // Check if bubble-pop-up.js is installed as a resource and remove it (fix for the previous 1.5.0/1 users) + if (!window.resourceCleared) { + //let url = "/hacsfiles/Bubble-Card/bubble-pop-up.js"; + addResource(hass); + window.resourceCleared = true; + } + // Initialize the content if it's not there yet. if (!this.content) { this.attachShadow({