Use base64 instead of blob URLs

This commit is contained in:
Justin Wong
2022-08-05 02:22:14 +08:00
parent fde2cc5d60
commit 0317114879
+14 -4
View File
@@ -54,10 +54,20 @@ export class FrigateCardThumbnailFeatureEvent extends LitElement {
if (this.thumbnail?.startsWith('data:')) { if (this.thumbnail?.startsWith('data:')) {
return this.thumbnail; return this.thumbnail;
} }
return await this.hass return new Promise((resolve, reject) => {
.fetchWithAuth(thumbnail) //eslint-disable-next-line @typescript-eslint/no-non-null-assertion
.then((response) => response.blob()) this.hass!.fetchWithAuth(thumbnail)
.then((blob) => URL.createObjectURL(blob)); .then((response) => response.blob())
.then((blob) => {
const reader = new FileReader();
reader.onload = () => {
const result = reader.result;
resolve(typeof result === 'string' ? result : null);
};
reader.onerror = (e) => reject(e);
reader.readAsDataURL(blob);
});
});
} }
protected render(): TemplateResult | void { protected render(): TemplateResult | void {