mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Adds throttler to config pages for state entity updates (#21646)
throttler
This commit is contained in:
parent
6b99cda982
commit
00eb820e36
@ -51,6 +51,7 @@ import { SubscribeMixin } from "../../mixins/subscribe-mixin";
|
|||||||
import { HomeAssistant, Route } from "../../types";
|
import { HomeAssistant, Route } from "../../types";
|
||||||
import { subscribeLabelRegistry } from "../../data/label_registry";
|
import { subscribeLabelRegistry } from "../../data/label_registry";
|
||||||
import { subscribeFloorRegistry } from "../../data/floor_registry";
|
import { subscribeFloorRegistry } from "../../data/floor_registry";
|
||||||
|
import { throttle } from "../../common/util/throttle";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
// for fire event
|
// for fire event
|
||||||
@ -395,6 +396,10 @@ class HaPanelConfig extends SubscribeMixin(HassRouterPage) {
|
|||||||
initialValue: [],
|
initialValue: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
private _hassThrottler = throttle((el, hass) => {
|
||||||
|
el.hass = hass;
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
public hassSubscribe(): UnsubscribeFunc[] {
|
public hassSubscribe(): UnsubscribeFunc[] {
|
||||||
return [
|
return [
|
||||||
subscribeEntityRegistry(this.hass.connection!, (entities) => {
|
subscribeEntityRegistry(this.hass.connection!, (entities) => {
|
||||||
@ -641,7 +646,11 @@ class HaPanelConfig extends SubscribeMixin(HassRouterPage) {
|
|||||||
this.hass.dockedSidebar === "docked" ? this._wideSidebar : this._wide;
|
this.hass.dockedSidebar === "docked" ? this._wideSidebar : this._wide;
|
||||||
|
|
||||||
el.route = this.routeTail;
|
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.showAdvanced = Boolean(this.hass.userData?.showAdvanced);
|
||||||
el.isWide = isWide;
|
el.isWide = isWide;
|
||||||
el.narrow = this.narrow;
|
el.narrow = this.narrow;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user