Fix for icons with firefox private mode (#5985)
This commit is contained in:
parent
4ad3dbf3e2
commit
3640960486
|
@ -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;
|
||||
|
|
|
@ -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<string>((resolve) => {
|
||||
toRead.push([iconName, resolve]);
|
||||
new Promise<string>((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 = [];
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ export class HuiMarkdownCard extends LitElement implements LovelaceCard {
|
|||
},
|
||||
}
|
||||
);
|
||||
} catch {
|
||||
} catch (_err) {
|
||||
this._content = this._config!.content;
|
||||
this._unsubRenderTemplate = undefined;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue