mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix notifications subscription leak when in narrow mode (#16953)
Fix persistent notifications subscription leak on mobile/narrow
This commit is contained in:
parent
79c010eb7b
commit
2b51228665
@ -74,11 +74,16 @@ class HaMenuButton extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const oldHass = changedProps.get("hass") as HomeAssistant | undefined;
|
const oldHass = changedProps.get("hass") as HomeAssistant | undefined;
|
||||||
const oldNarrow =
|
|
||||||
changedProps.get("narrow") ||
|
let oldNarrow: boolean | undefined;
|
||||||
(oldHass && oldHass.dockedSidebar === "always_hidden");
|
let newNarrow: boolean | undefined;
|
||||||
const newNarrow =
|
if (changedProps.has("narrow")) {
|
||||||
this.narrow || this.hass.dockedSidebar === "always_hidden";
|
oldNarrow = changedProps.get("narrow");
|
||||||
|
newNarrow = this.narrow;
|
||||||
|
} else if (oldHass) {
|
||||||
|
oldNarrow = oldHass.dockedSidebar === "always_hidden";
|
||||||
|
newNarrow = this.hass.dockedSidebar === "always_hidden";
|
||||||
|
}
|
||||||
|
|
||||||
if (oldNarrow === newNarrow) {
|
if (oldNarrow === newNarrow) {
|
||||||
return;
|
return;
|
||||||
@ -98,6 +103,9 @@ class HaMenuButton extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _subscribeNotifications() {
|
private _subscribeNotifications() {
|
||||||
|
if (this._unsubNotifications) {
|
||||||
|
throw new Error("Already subscribed");
|
||||||
|
}
|
||||||
this._unsubNotifications = subscribeNotifications(
|
this._unsubNotifications = subscribeNotifications(
|
||||||
this.hass.connection,
|
this.hass.connection,
|
||||||
(notifications) => {
|
(notifications) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user