From 4cb71549175748b41ae52f98785ce79092557a8c Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 9 Jan 2022 03:40:36 -0800 Subject: [PATCH] Hide local webhooks (#11123) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Joakim Sørensen --- src/data/webhook.ts | 1 + src/panels/config/cloud/account/cloud-webhooks.ts | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/data/webhook.ts b/src/data/webhook.ts index c3d96dc11f..1332de74b2 100644 --- a/src/data/webhook.ts +++ b/src/data/webhook.ts @@ -4,6 +4,7 @@ export interface Webhook { webhook_id: string; domain: string; name: string; + local_only: boolean; } export interface WebhookError { code: number; diff --git a/src/panels/config/cloud/account/cloud-webhooks.ts b/src/panels/config/cloud/account/cloud-webhooks.ts index 3fde6744cf..6f31ea5b52 100644 --- a/src/panels/config/cloud/account/cloud-webhooks.ts +++ b/src/panels/config/cloud/account/cloud-webhooks.ts @@ -195,9 +195,18 @@ export class CloudWebhooks extends LitElement { } private async _fetchData() { - this._localHooks = isComponentLoaded(this.hass!, "webhook") - ? await fetchWebhooks(this.hass!) - : []; + if (!isComponentLoaded(this.hass!, "webhook")) { + this._localHooks = []; + return; + } + const hooks = await fetchWebhooks(this.hass!); + this._localHooks = hooks.filter( + (hook) => + // Only hooks that are not limited to local requests are relevant + !hook.local_only && + // Deleted webhooks -> nobody cares :) + (hook.domain !== "mobile_app" || hook.name !== "Deleted Webhook") + ); } static get styles(): CSSResultGroup {