web: improve loading of custom favicon
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
@ -26,10 +26,20 @@ let globalTenantPromise: Promise<CurrentTenant>;
|
||||
export function tenant(): Promise<CurrentTenant> {
|
||||
if (!globalTenantPromise) {
|
||||
globalTenantPromise = new CoreApi(DEFAULT_CONFIG).coreTenantsCurrentRetrieve().then(tenant => {
|
||||
const relIcon = document.head.querySelector<HTMLLinkElement>("link[rel=icon]");
|
||||
if (relIcon) {
|
||||
/**
|
||||
* <link rel="icon" href="/static/dist/assets/icons/icon.png">
|
||||
* <link rel="shortcut icon" href="/static/dist/assets/icons/icon.png">
|
||||
*/
|
||||
const rels = ["icon", "shortcut icon"];
|
||||
rels.forEach(rel => {
|
||||
let relIcon = document.head.querySelector<HTMLLinkElement>("link[rel=icon]");
|
||||
if (!relIcon) {
|
||||
relIcon = document.createElement('link');
|
||||
relIcon.rel = rel;
|
||||
document.getElementsByTagName('head')[0].appendChild(relIcon);
|
||||
}
|
||||
relIcon.href = tenant.brandingLogo;
|
||||
}
|
||||
})
|
||||
return tenant;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user