diff --git a/src/components/ha-icon.ts b/src/components/ha-icon.ts index 7f1bfc57c9..7a8eee1896 100644 --- a/src/components/ha-icon.ts +++ b/src/components/ha-icon.ts @@ -90,7 +90,14 @@ export class HaIcon extends LitElement { return; } - const databaseIcon: string = await getIcon(iconName); + let databaseIcon: string | undefined; + try { + databaseIcon = await getIcon(iconName); + } catch (_err) { + // Firefox in private mode doesn't support IDB + databaseIcon = undefined; + } + if (databaseIcon) { this._path = databaseIcon; cachedIcons[iconName] = databaseIcon; diff --git a/src/data/iconsets.ts b/src/data/iconsets.ts index 1f28e7dd80..941f84cd74 100644 --- a/src/data/iconsets.ts +++ b/src/data/iconsets.ts @@ -14,12 +14,12 @@ export const iconStore = new Store("hass-icon-db", "mdi-icon-store"); export const MDI_PREFIXES = ["mdi", "hass", "hassio", "hademo"]; -let toRead: Array<[string, (string) => void]> = []; +let toRead: Array<[string, (string) => void, () => void]> = []; // Queue up as many icon fetches in 1 transaction export const getIcon = (iconName: string) => - new Promise((resolve) => { - toRead.push([iconName, resolve]); + new Promise((resolve, reject) => { + toRead.push([iconName, resolve, reject]); if (toRead.length > 1) { return; @@ -38,6 +38,13 @@ export const getIcon = (iconName: string) => for (const [resolve_, request] of results) { resolve_(request.result); } + }) + .catch(() => { + // Firefox in private mode doesn't support IDB + for (const [, , reject_] of toRead) { + reject_(); + } + toRead = []; }); }); diff --git a/src/panels/lovelace/cards/hui-markdown-card.ts b/src/panels/lovelace/cards/hui-markdown-card.ts index 54f6d3fda2..475531c578 100644 --- a/src/panels/lovelace/cards/hui-markdown-card.ts +++ b/src/panels/lovelace/cards/hui-markdown-card.ts @@ -136,7 +136,7 @@ export class HuiMarkdownCard extends LitElement implements LovelaceCard { }, } ); - } catch { + } catch (_err) { this._content = this._config!.content; this._unsubRenderTemplate = undefined; }