mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 19:26:36 +00:00
Fix persistent notification count on server restart (#21405)
* Fix persistent notification count on server restart
This commit is contained in:
parent
d997cfcef0
commit
e63d82d291
@ -210,6 +210,8 @@ class HaSidebar extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
private _editStyleLoaded = false;
|
private _editStyleLoaded = false;
|
||||||
|
|
||||||
|
private _unsubPersistentNotifications: UnsubscribeFunc | undefined;
|
||||||
|
|
||||||
@storage({
|
@storage({
|
||||||
key: "sidebarPanelOrder",
|
key: "sidebarPanelOrder",
|
||||||
state: true,
|
state: true,
|
||||||
@ -283,15 +285,26 @@ class HaSidebar extends SubscribeMixin(LitElement) {
|
|||||||
hass.localize !== oldHass.localize ||
|
hass.localize !== oldHass.localize ||
|
||||||
hass.locale !== oldHass.locale ||
|
hass.locale !== oldHass.locale ||
|
||||||
hass.states !== oldHass.states ||
|
hass.states !== oldHass.states ||
|
||||||
hass.defaultPanel !== oldHass.defaultPanel
|
hass.defaultPanel !== oldHass.defaultPanel ||
|
||||||
|
hass.connected !== oldHass.connected
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected firstUpdated(changedProps: PropertyValues) {
|
protected firstUpdated(changedProps: PropertyValues) {
|
||||||
super.firstUpdated(changedProps);
|
super.firstUpdated(changedProps);
|
||||||
subscribeNotifications(this.hass.connection, (notifications) => {
|
this.subscribePersistentNotifications();
|
||||||
|
}
|
||||||
|
|
||||||
|
private subscribePersistentNotifications(): void {
|
||||||
|
if (this._unsubPersistentNotifications) {
|
||||||
|
this._unsubPersistentNotifications();
|
||||||
|
}
|
||||||
|
this._unsubPersistentNotifications = subscribeNotifications(
|
||||||
|
this.hass.connection,
|
||||||
|
(notifications) => {
|
||||||
this._notifications = notifications;
|
this._notifications = notifications;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected updated(changedProps) {
|
protected updated(changedProps) {
|
||||||
@ -306,6 +319,14 @@ class HaSidebar extends SubscribeMixin(LitElement) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.hass &&
|
||||||
|
changedProps.get("hass")?.connected === false &&
|
||||||
|
this.hass.connected === true
|
||||||
|
) {
|
||||||
|
this.subscribePersistentNotifications();
|
||||||
|
}
|
||||||
|
|
||||||
this._calculateCounts();
|
this._calculateCounts();
|
||||||
|
|
||||||
if (!SUPPORT_SCROLL_IF_NEEDED) {
|
if (!SUPPORT_SCROLL_IF_NEEDED) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user