Skip to content

Commit

Permalink
Adds throttler to config pages for state entity updates (#21646)
Browse files Browse the repository at this point in the history
throttler
  • Loading branch information
silamon authored Aug 28, 2024
1 parent 6b99cda commit 00eb820
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/panels/config/ha-panel-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 00eb820

Please sign in to comment.