From 507628873e0c96d19cb4667d5af2fa817dd4f82d Mon Sep 17 00:00:00 2001 From: Justin Wong <46082645+uvjustin@users.noreply.github.com> Date: Fri, 5 Aug 2022 12:14:00 +0800 Subject: [PATCH] Reject if !this.hass --- src/components/thumbnail.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/thumbnail.ts b/src/components/thumbnail.ts index 913a8005..ddd1a2e6 100644 --- a/src/components/thumbnail.ts +++ b/src/components/thumbnail.ts @@ -55,12 +55,16 @@ export class FrigateCardThumbnailFeatureEvent extends LitElement { return this.thumbnail; } return new Promise((resolve, reject) => { - //eslint-disable-next-line @typescript-eslint/no-non-null-assertion - this.hass!.fetchWithAuth(thumbnail) - // Since we are fetching with an authorization header, we cannot just put the - // URL directly into the document; we need to embed the image. We could do this - // using blob URLs, but then we would need to keep track of them in order to - // release them properly. Instead, we embed the thumbnail using base64. + if (!this.hass) { + reject(); + return; + } + this.hass + .fetchWithAuth(thumbnail) + // Since we are fetching with an authorization header, we cannot just put the + // URL directly into the document; we need to embed the image. We could do this + // using blob URLs, but then we would need to keep track of them in order to + // release them properly. Instead, we embed the thumbnail using base64. .then((response) => response.blob()) .then((blob) => { const reader = new FileReader();