From 9500ac498ce41fede4560a57852ed7cc5eae995c Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 18 Feb 2022 06:04:45 -0800 Subject: [PATCH] Debounce refresh the cloud status if Google events happen (#11721) --- src/panels/config/cloud/account/cloud-account.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/panels/config/cloud/account/cloud-account.ts b/src/panels/config/cloud/account/cloud-account.ts index 63ea847326..15e5d3c002 100644 --- a/src/panels/config/cloud/account/cloud-account.ts +++ b/src/panels/config/cloud/account/cloud-account.ts @@ -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) {