Do not fire command if we know component not loaded (#2875)

This commit is contained in:
Paulus Schoutsen 2019-03-03 10:26:10 -08:00 committed by GitHub
parent 34c6356a47
commit 241d7345d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,7 +20,6 @@ import {
deleteCloudhook,
CloudWebhook,
} from "../../../data/cloud";
import { ERR_UNKNOWN_COMMAND } from "../../../data/websocket_api";
declare global {
// for fire event
@ -196,15 +195,10 @@ export class CloudWebhooks extends LitElement {
}
private async _fetchData() {
try {
this._localHooks = await fetchWebhooks(this.hass!);
} catch (err) {
if (err.code === ERR_UNKNOWN_COMMAND) {
this._localHooks = [];
} else {
throw err;
}
}
this._localHooks =
"webhook" in this.hass!.config.components
? await fetchWebhooks(this.hass!)
: [];
}
private renderStyle() {