Prevent recreation of entities row on every update of hass (#5657)

This commit is contained in:
Bram Kragten 2020-04-29 22:29:53 +02:00 committed by GitHub
parent 8029c3d672
commit 1fdb6b8034
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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