mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Fixes history unsubcription (#15271)
* Fixes history unsubcriptions * Remove async
This commit is contained in:
parent
acf9bca038
commit
9220d65f78
@ -113,20 +113,15 @@ export class MoreInfoHistory extends LitElement {
|
||||
|
||||
public disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
this._unsubscribeHistoryTimeWindow();
|
||||
this._unsubscribeHistory();
|
||||
}
|
||||
|
||||
private _unsubscribeHistoryTimeWindow() {
|
||||
if (!this._subscribed) {
|
||||
return;
|
||||
}
|
||||
private _unsubscribeHistory() {
|
||||
clearInterval(this._interval);
|
||||
this._subscribed.then((unsubscribe) => {
|
||||
if (unsubscribe) {
|
||||
unsubscribe();
|
||||
}
|
||||
if (this._subscribed) {
|
||||
this._subscribed.then((unsub) => unsub?.());
|
||||
this._subscribed = undefined;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private _redrawGraph() {
|
||||
@ -165,7 +160,7 @@ export class MoreInfoHistory extends LitElement {
|
||||
return;
|
||||
}
|
||||
if (this._subscribed) {
|
||||
this._unsubscribeHistoryTimeWindow();
|
||||
this._unsubscribeHistory();
|
||||
}
|
||||
this._subscribed = subscribeHistoryStatesTimeWindow(
|
||||
this.hass!,
|
||||
|
@ -94,7 +94,7 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
||||
this._unsubscribeHistory();
|
||||
}
|
||||
|
||||
private async _subscribeHistory() {
|
||||
private _subscribeHistory() {
|
||||
if (!isComponentLoaded(this.hass!, "history") || this._subscribed) {
|
||||
return;
|
||||
}
|
||||
|
@ -191,16 +191,16 @@ class HuiMapCard extends LitElement implements LovelaceCard {
|
||||
public connectedCallback() {
|
||||
super.connectedCallback();
|
||||
if (this.hasUpdated && this._configEntities?.length) {
|
||||
this._subscribeHistoryTimeWindow();
|
||||
this._subscribeHistory();
|
||||
}
|
||||
}
|
||||
|
||||
public disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
this._unsubscribeHistoryTimeWindow();
|
||||
this._unsubscribeHistory();
|
||||
}
|
||||
|
||||
private _subscribeHistoryTimeWindow() {
|
||||
private _subscribeHistory() {
|
||||
if (!isComponentLoaded(this.hass!, "history") || this._subscribed) {
|
||||
return;
|
||||
}
|
||||
@ -223,26 +223,21 @@ class HuiMapCard extends LitElement implements LovelaceCard {
|
||||
});
|
||||
}
|
||||
|
||||
private _unsubscribeHistoryTimeWindow() {
|
||||
if (!this._subscribed) {
|
||||
return;
|
||||
}
|
||||
this._subscribed.then((unsubscribe) => {
|
||||
if (unsubscribe) {
|
||||
unsubscribe();
|
||||
}
|
||||
private _unsubscribeHistory() {
|
||||
if (this._subscribed) {
|
||||
this._subscribed.then((unsub) => unsub?.());
|
||||
this._subscribed = undefined;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected updated(changedProps: PropertyValues): void {
|
||||
if (this._configEntities?.length) {
|
||||
if (!this._subscribed || changedProps.has("_config")) {
|
||||
this._unsubscribeHistoryTimeWindow();
|
||||
this._subscribeHistoryTimeWindow();
|
||||
this._unsubscribeHistory();
|
||||
this._subscribeHistory();
|
||||
}
|
||||
} else {
|
||||
this._unsubscribeHistoryTimeWindow();
|
||||
this._unsubscribeHistory();
|
||||
}
|
||||
if (changedProps.has("_config")) {
|
||||
this._computePadding();
|
||||
|
@ -132,16 +132,16 @@ export class HuiGraphHeaderFooter
|
||||
public connectedCallback() {
|
||||
super.connectedCallback();
|
||||
if (this.hasUpdated) {
|
||||
this._subscribeHistoryTimeWindow();
|
||||
this._subscribeHistory();
|
||||
}
|
||||
}
|
||||
|
||||
public disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
this._unsubscribeHistoryTimeWindow();
|
||||
this._unsubscribeHistory();
|
||||
}
|
||||
|
||||
private _subscribeHistoryTimeWindow() {
|
||||
private _subscribeHistory() {
|
||||
if (!isComponentLoaded(this.hass!, "history") || this._subscribed) {
|
||||
return;
|
||||
}
|
||||
@ -185,17 +185,12 @@ export class HuiGraphHeaderFooter
|
||||
);
|
||||
}
|
||||
|
||||
private _unsubscribeHistoryTimeWindow() {
|
||||
private _unsubscribeHistory() {
|
||||
clearInterval(this._interval);
|
||||
if (!this._subscribed) {
|
||||
return;
|
||||
}
|
||||
this._subscribed.then((unsubscribe) => {
|
||||
if (unsubscribe) {
|
||||
unsubscribe();
|
||||
}
|
||||
if (this._subscribed) {
|
||||
this._subscribed.then((unsub) => unsub?.());
|
||||
this._subscribed = undefined;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected updated(changedProps: PropertyValues) {
|
||||
@ -209,8 +204,8 @@ export class HuiGraphHeaderFooter
|
||||
!this._subscribed ||
|
||||
oldConfig.entity !== this._config.entity
|
||||
) {
|
||||
this._unsubscribeHistoryTimeWindow();
|
||||
this._subscribeHistoryTimeWindow();
|
||||
this._unsubscribeHistory();
|
||||
this._subscribeHistory();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user