Fix demo suspend once and for all (#6219)

This commit is contained in:
Paulus Schoutsen 2020-06-23 11:07:01 -07:00 committed by GitHub
parent 44210ce6f2
commit 7637d36146
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -114,6 +114,7 @@ export const provideHass = (
);
const localLanguage = getLocalLanguage();
const noop = () => undefined;
const hassObj: MockHomeAssistant = {
// Home Assistant properties
@ -123,8 +124,8 @@ export const provideHass = (
},
} as any,
connection: {
addEventListener: () => undefined,
removeEventListener: () => undefined,
addEventListener: noop,
removeEventListener: noop,
sendMessage: (msg) => {
const callback = wsCommands[msg.type];
@ -168,6 +169,8 @@ export const provideHass = (
);
};
},
suspendReconnectUntil: noop,
suspend: noop,
socket: {
readyState: WebSocket.OPEN,
},

View File

@ -78,7 +78,7 @@ export class HomeAssistantAppEl extends HassElement {
document.addEventListener(
"visibilitychange",
() => this.__handleVisibilityChange(),
() => this._handleVisibilityChange(),
false
);
}
@ -148,7 +148,7 @@ export class HomeAssistantAppEl extends HassElement {
: route.path.substr(1, dividerPos - 1);
}
private __handleVisibilityChange() {
protected _handleVisibilityChange() {
if (document.hidden) {
// If the document is hidden, we will prevent reconnects until we are visible again
this.hass!.connection.suspendReconnectUntil(