From 00eb820e368125fa4611e19816ecd2b7908187c9 Mon Sep 17 00:00:00 2001 From: Simon Lamon <32477463+silamon@users.noreply.github.com> Date: Wed, 28 Aug 2024 08:27:28 +0200 Subject: [PATCH] Adds throttler to config pages for state entity updates (#21646) throttler --- src/panels/config/ha-panel-config.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/panels/config/ha-panel-config.ts b/src/panels/config/ha-panel-config.ts index fe3151b2603d..f29999124512 100644 --- a/src/panels/config/ha-panel-config.ts +++ b/src/panels/config/ha-panel-config.ts @@ -51,6 +51,7 @@ import { SubscribeMixin } from "../../mixins/subscribe-mixin"; import { HomeAssistant, Route } from "../../types"; import { subscribeLabelRegistry } from "../../data/label_registry"; import { subscribeFloorRegistry } from "../../data/floor_registry"; +import { throttle } from "../../common/util/throttle"; declare global { // for fire event @@ -395,6 +396,10 @@ class HaPanelConfig extends SubscribeMixin(HassRouterPage) { initialValue: [], }); + private _hassThrottler = throttle((el, hass) => { + el.hass = hass; + }, 1000); + public hassSubscribe(): UnsubscribeFunc[] { return [ subscribeEntityRegistry(this.hass.connection!, (entities) => { @@ -641,7 +646,11 @@ class HaPanelConfig extends SubscribeMixin(HassRouterPage) { this.hass.dockedSidebar === "docked" ? this._wideSidebar : this._wide; el.route = this.routeTail; - el.hass = this.hass; + if (el.hass !== undefined) { + this._hassThrottler(el, this.hass); + } else { + el.hass = this.hass; + } el.showAdvanced = Boolean(this.hass.userData?.showAdvanced); el.isWide = isWide; el.narrow = this.narrow;