Hide local webhooks (#11123)

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
This commit is contained in:
Paulus Schoutsen 2022-01-09 03:40:36 -08:00 committed by GitHub
parent 08863348dc
commit 4cb7154917
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -4,6 +4,7 @@ export interface Webhook {
webhook_id: string;
domain: string;
name: string;
local_only: boolean;
}
export interface WebhookError {
code: number;

View File

@ -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 {