mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 10:16:46 +00:00
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;
|
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) {
|
if (databaseIcon) {
|
||||||
this._path = databaseIcon;
|
this._path = databaseIcon;
|
||||||
cachedIcons[iconName] = 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"];
|
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
|
// Queue up as many icon fetches in 1 transaction
|
||||||
export const getIcon = (iconName: string) =>
|
export const getIcon = (iconName: string) =>
|
||||||
new Promise<string>((resolve) => {
|
new Promise<string>((resolve, reject) => {
|
||||||
toRead.push([iconName, resolve]);
|
toRead.push([iconName, resolve, reject]);
|
||||||
|
|
||||||
if (toRead.length > 1) {
|
if (toRead.length > 1) {
|
||||||
return;
|
return;
|
||||||
@ -38,6 +38,13 @@ export const getIcon = (iconName: string) =>
|
|||||||
for (const [resolve_, request] of results) {
|
for (const [resolve_, request] of results) {
|
||||||
resolve_(request.result);
|
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._content = this._config!.content;
|
||||||
this._unsubRenderTemplate = undefined;
|
this._unsubRenderTemplate = undefined;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user