Debounce refresh the cloud status if Google events happen (#11721)

This commit is contained in:
Paulus Schoutsen 2022-02-18 06:04:45 -08:00 committed by GitHub
parent 5c5459bcaf
commit 9500ac498c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,6 +12,7 @@ import "../../../../components/buttons/ha-call-api-button";
import "../../../../components/ha-card";
import "../../../../components/ha-button-menu";
import "../../../../components/ha-icon-button";
import { debounce } from "../../../../common/util/debounce";
import {
cloudLogout,
CloudStatusLoggedIn,
@ -219,11 +220,15 @@ export class CloudAccount extends SubscribeMixin(LitElement) {
}
protected override hassSubscribe() {
const googleCheck = () => {
if (!this.cloudStatus?.google_registered) {
fireEvent(this, "ha-refresh-cloud-status");
}
};
const googleCheck = debounce(
() => {
if (this.cloudStatus && !this.cloudStatus.google_registered) {
fireEvent(this, "ha-refresh-cloud-status");
}
},
10000,
true
);
return [
this.hass.connection.subscribeEvents(() => {
if (!this.cloudStatus?.alexa_registered) {