From 1fdb6b80343d297a0007f1c63442a62688e7a6a6 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 29 Apr 2020 22:29:53 +0200 Subject: [PATCH] Prevent recreation of entities row on every update of hass (#5657) --- .../device-detail/ha-device-entities-card.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/panels/config/devices/device-detail/ha-device-entities-card.ts b/src/panels/config/devices/device-detail/ha-device-entities-card.ts index 23bb2af680..649cecfc3c 100644 --- a/src/panels/config/devices/device-detail/ha-device-entities-card.ts +++ b/src/panels/config/devices/device-detail/ha-device-entities-card.ts @@ -28,24 +28,20 @@ import { EntityRegistryStateEntry } from "../ha-config-device-page"; export class HaDeviceEntitiesCard extends LitElement { @property() public hass!: HomeAssistant; - @property() public deviceId!: string; - @property() public entities!: EntityRegistryStateEntry[]; - @property() public narrow!: boolean; - @property() private _showDisabled = false; @queryAll("#entities > *") private _entityRows?: LovelaceRow[]; - protected updated(changedProps: PropertyValues): void { - super.updated(changedProps); - if (!changedProps.has("hass")) { - return; + protected shouldUpdate(changedProps: PropertyValues) { + if (changedProps.has("hass")) { + this._entityRows?.forEach((element) => { + element.hass = this.hass; + }); + return changedProps.size > 1; } - this._entityRows?.forEach((element) => { - element.hass = this.hass; - }); + return true; } protected render(): TemplateResult {