mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 03:06:41 +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() {
|
public disconnectedCallback() {
|
||||||
super.disconnectedCallback();
|
super.disconnectedCallback();
|
||||||
this._unsubscribeHistoryTimeWindow();
|
this._unsubscribeHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _unsubscribeHistoryTimeWindow() {
|
private _unsubscribeHistory() {
|
||||||
if (!this._subscribed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
clearInterval(this._interval);
|
clearInterval(this._interval);
|
||||||
this._subscribed.then((unsubscribe) => {
|
if (this._subscribed) {
|
||||||
if (unsubscribe) {
|
this._subscribed.then((unsub) => unsub?.());
|
||||||
unsubscribe();
|
|
||||||
}
|
|
||||||
this._subscribed = undefined;
|
this._subscribed = undefined;
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _redrawGraph() {
|
private _redrawGraph() {
|
||||||
@ -165,7 +160,7 @@ export class MoreInfoHistory extends LitElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this._subscribed) {
|
if (this._subscribed) {
|
||||||
this._unsubscribeHistoryTimeWindow();
|
this._unsubscribeHistory();
|
||||||
}
|
}
|
||||||
this._subscribed = subscribeHistoryStatesTimeWindow(
|
this._subscribed = subscribeHistoryStatesTimeWindow(
|
||||||
this.hass!,
|
this.hass!,
|
||||||
|
@ -94,7 +94,7 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
|||||||
this._unsubscribeHistory();
|
this._unsubscribeHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _subscribeHistory() {
|
private _subscribeHistory() {
|
||||||
if (!isComponentLoaded(this.hass!, "history") || this._subscribed) {
|
if (!isComponentLoaded(this.hass!, "history") || this._subscribed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -191,16 +191,16 @@ class HuiMapCard extends LitElement implements LovelaceCard {
|
|||||||
public connectedCallback() {
|
public connectedCallback() {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
if (this.hasUpdated && this._configEntities?.length) {
|
if (this.hasUpdated && this._configEntities?.length) {
|
||||||
this._subscribeHistoryTimeWindow();
|
this._subscribeHistory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public disconnectedCallback() {
|
public disconnectedCallback() {
|
||||||
super.disconnectedCallback();
|
super.disconnectedCallback();
|
||||||
this._unsubscribeHistoryTimeWindow();
|
this._unsubscribeHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _subscribeHistoryTimeWindow() {
|
private _subscribeHistory() {
|
||||||
if (!isComponentLoaded(this.hass!, "history") || this._subscribed) {
|
if (!isComponentLoaded(this.hass!, "history") || this._subscribed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -223,26 +223,21 @@ class HuiMapCard extends LitElement implements LovelaceCard {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _unsubscribeHistoryTimeWindow() {
|
private _unsubscribeHistory() {
|
||||||
if (!this._subscribed) {
|
if (this._subscribed) {
|
||||||
return;
|
this._subscribed.then((unsub) => unsub?.());
|
||||||
}
|
|
||||||
this._subscribed.then((unsubscribe) => {
|
|
||||||
if (unsubscribe) {
|
|
||||||
unsubscribe();
|
|
||||||
}
|
|
||||||
this._subscribed = undefined;
|
this._subscribed = undefined;
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected updated(changedProps: PropertyValues): void {
|
protected updated(changedProps: PropertyValues): void {
|
||||||
if (this._configEntities?.length) {
|
if (this._configEntities?.length) {
|
||||||
if (!this._subscribed || changedProps.has("_config")) {
|
if (!this._subscribed || changedProps.has("_config")) {
|
||||||
this._unsubscribeHistoryTimeWindow();
|
this._unsubscribeHistory();
|
||||||
this._subscribeHistoryTimeWindow();
|
this._subscribeHistory();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this._unsubscribeHistoryTimeWindow();
|
this._unsubscribeHistory();
|
||||||
}
|
}
|
||||||
if (changedProps.has("_config")) {
|
if (changedProps.has("_config")) {
|
||||||
this._computePadding();
|
this._computePadding();
|
||||||
|
@ -132,16 +132,16 @@ export class HuiGraphHeaderFooter
|
|||||||
public connectedCallback() {
|
public connectedCallback() {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
if (this.hasUpdated) {
|
if (this.hasUpdated) {
|
||||||
this._subscribeHistoryTimeWindow();
|
this._subscribeHistory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public disconnectedCallback() {
|
public disconnectedCallback() {
|
||||||
super.disconnectedCallback();
|
super.disconnectedCallback();
|
||||||
this._unsubscribeHistoryTimeWindow();
|
this._unsubscribeHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _subscribeHistoryTimeWindow() {
|
private _subscribeHistory() {
|
||||||
if (!isComponentLoaded(this.hass!, "history") || this._subscribed) {
|
if (!isComponentLoaded(this.hass!, "history") || this._subscribed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -185,17 +185,12 @@ export class HuiGraphHeaderFooter
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _unsubscribeHistoryTimeWindow() {
|
private _unsubscribeHistory() {
|
||||||
clearInterval(this._interval);
|
clearInterval(this._interval);
|
||||||
if (!this._subscribed) {
|
if (this._subscribed) {
|
||||||
return;
|
this._subscribed.then((unsub) => unsub?.());
|
||||||
}
|
|
||||||
this._subscribed.then((unsubscribe) => {
|
|
||||||
if (unsubscribe) {
|
|
||||||
unsubscribe();
|
|
||||||
}
|
|
||||||
this._subscribed = undefined;
|
this._subscribed = undefined;
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected updated(changedProps: PropertyValues) {
|
protected updated(changedProps: PropertyValues) {
|
||||||
@ -209,8 +204,8 @@ export class HuiGraphHeaderFooter
|
|||||||
!this._subscribed ||
|
!this._subscribed ||
|
||||||
oldConfig.entity !== this._config.entity
|
oldConfig.entity !== this._config.entity
|
||||||
) {
|
) {
|
||||||
this._unsubscribeHistoryTimeWindow();
|
this._unsubscribeHistory();
|
||||||
this._subscribeHistoryTimeWindow();
|
this._subscribeHistory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user