1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-04-02 00:27:49 +01:00

Fix entities not updated in device page (#30136)

This commit is contained in:
Paul Bottein
2026-03-13 10:11:11 +01:00
committed by GitHub
parent 148d01b05b
commit d851a5bdf3
2 changed files with 21 additions and 16 deletions

View File

@@ -3,7 +3,6 @@ import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { until } from "lit/directives/until";
import { computeEntityName } from "../../../../common/entity/compute_entity_name";
import { stripPrefixFromEntityName } from "../../../../common/entity/strip_prefix_from_entity_name";
import "../../../../components/ha-button";
import "../../../../components/ha-card";
@@ -170,11 +169,8 @@ export class HaDeviceEntitiesCard extends LitElement {
const element = createRowElement(config);
if (this.hass) {
element.hass = this.hass;
const stateObj = this.hass.states[entry.entity_id];
let name =
computeEntityName(stateObj, this.hass.entities, this.hass.devices) ||
this.deviceName;
let name = entry.stateName || this.deviceName;
if (entry.hidden_by) {
name += ` (${this.hass.localize(

View File

@@ -178,6 +178,12 @@ export class LazyContextProvider<
originalCallback: (value: T, unsubscribe?: () => void) => void
): (value: T, unsubscribe?: () => void) => void {
let tracked = false;
// Keep stable references so ContextConsumer doesn't think the
// subscription changed and call the old disposer (which removes
// the subscription from the inner provider's map).
let cachedDisposer: (() => void) | undefined;
let cachedWrappedDisposer: (() => void) | undefined;
return (value: T, disposer?: () => void) => {
if (!tracked && disposer) {
// First call with a disposer — this consumer is now subscribed.
@@ -186,20 +192,23 @@ export class LazyContextProvider<
this._clearTeardownTimer();
}
const wrappedDisposer = disposer
? () => {
if (tracked) {
tracked = false;
this._subscriberCount--;
if (this._subscriberCount === 0 && this._loaded) {
this._scheduleTeardown();
if (disposer !== cachedDisposer) {
cachedDisposer = disposer;
cachedWrappedDisposer = disposer
? () => {
if (tracked) {
tracked = false;
this._subscriberCount--;
if (this._subscriberCount === 0 && this._loaded) {
this._scheduleTeardown();
}
}
disposer();
}
disposer();
}
: undefined;
: undefined;
}
originalCallback(value, wrappedDisposer);
originalCallback(value, cachedWrappedDisposer);
};
}