From e8b065ea4e23fd097d06e57db5556209c51b62c0 Mon Sep 17 00:00:00 2001 From: Aalian Khan Date: Tue, 28 Mar 2023 15:10:05 -0400 Subject: [PATCH] Fix bug where multiple entries in entity_config creates duplicates --- dist/mushroom-strategy.js | 51 +++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/dist/mushroom-strategy.js b/dist/mushroom-strategy.js index d0f454e..910b2a9 100644 --- a/dist/mushroom-strategy.js +++ b/dist/mushroom-strategy.js @@ -110,7 +110,8 @@ const createPlatformCard = (entities, entity_config, defaultCard, titleCard, dou if (titleCard != null) { platformCards.push(titleCard); } - + + entitiesLoop: for (const entity of entities) { // Entity config does not exist then push defualt card, otherwise loop to find matching entity @@ -148,35 +149,37 @@ const createPlatformCard = (entities, entity_config, defaultCard, titleCard, dou ...config }, ); - - } else + continue entitiesLoop; + } + } + + if (doubleTapActionConfig != null) + { + var doubleTapAction = { - if (doubleTapActionConfig != null) { - var doubleTapAction = + double_tap_action: + { + target: { - double_tap_action: - { - target: - { - entity_id: entity.entity_id - }, - ...doubleTapActionConfig - } - } + entity_id: entity.entity_id + }, + ...doubleTapActionConfig } - platformCards.push - ( - { - entity: entity.entity_id, - ...defaultCard, - ...doubleTapAction - } - ) } } - } + platformCards.push + ( + { + entity: entity.entity_id, + ...defaultCard, + ...doubleTapAction + } + ) + } + } + return platformCards; } @@ -1306,4 +1309,4 @@ class MushroomStrategy { } } -customElements.define("ll-strategy-mushroom-strategy", MushroomStrategy); \ No newline at end of file +customElements.define("ll-strategy-mushroom-strategy", MushroomStrategy);