mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 18:56:39 +00:00
Fix demo suspend once and for all (#6219)
This commit is contained in:
parent
44210ce6f2
commit
7637d36146
@ -114,6 +114,7 @@ export const provideHass = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
const localLanguage = getLocalLanguage();
|
const localLanguage = getLocalLanguage();
|
||||||
|
const noop = () => undefined;
|
||||||
|
|
||||||
const hassObj: MockHomeAssistant = {
|
const hassObj: MockHomeAssistant = {
|
||||||
// Home Assistant properties
|
// Home Assistant properties
|
||||||
@ -123,8 +124,8 @@ export const provideHass = (
|
|||||||
},
|
},
|
||||||
} as any,
|
} as any,
|
||||||
connection: {
|
connection: {
|
||||||
addEventListener: () => undefined,
|
addEventListener: noop,
|
||||||
removeEventListener: () => undefined,
|
removeEventListener: noop,
|
||||||
sendMessage: (msg) => {
|
sendMessage: (msg) => {
|
||||||
const callback = wsCommands[msg.type];
|
const callback = wsCommands[msg.type];
|
||||||
|
|
||||||
@ -168,6 +169,8 @@ export const provideHass = (
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
suspendReconnectUntil: noop,
|
||||||
|
suspend: noop,
|
||||||
socket: {
|
socket: {
|
||||||
readyState: WebSocket.OPEN,
|
readyState: WebSocket.OPEN,
|
||||||
},
|
},
|
||||||
|
@ -78,7 +78,7 @@ export class HomeAssistantAppEl extends HassElement {
|
|||||||
|
|
||||||
document.addEventListener(
|
document.addEventListener(
|
||||||
"visibilitychange",
|
"visibilitychange",
|
||||||
() => this.__handleVisibilityChange(),
|
() => this._handleVisibilityChange(),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ export class HomeAssistantAppEl extends HassElement {
|
|||||||
: route.path.substr(1, dividerPos - 1);
|
: route.path.substr(1, dividerPos - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private __handleVisibilityChange() {
|
protected _handleVisibilityChange() {
|
||||||
if (document.hidden) {
|
if (document.hidden) {
|
||||||
// If the document is hidden, we will prevent reconnects until we are visible again
|
// If the document is hidden, we will prevent reconnects until we are visible again
|
||||||
this.hass!.connection.suspendReconnectUntil(
|
this.hass!.connection.suspendReconnectUntil(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user