Update readme

This commit is contained in:
2022-09-01 19:23:30 +00:00
parent fffb017287
commit 79cb58175b
5 changed files with 99 additions and 63 deletions

View File

@@ -4,6 +4,7 @@ export const AutoSettingsMixin = (SuperClass) => {
class AutoSettingsMixinClass extends SuperClass {
_faviconTemplateSubscription;
_titleTemplateSubscription;
_sidebarTitleSubscription;
__currentTitle = undefined;
@runOnce()
@@ -69,12 +70,18 @@ export const AutoSettingsMixin = (SuperClass) => {
// Sidebar title
if (settings.sidebarTitle) {
selectTree(
document,
"home-assistant $ home-assistant-main $ app-drawer-layout app-drawer ha-sidebar $ .title"
).then((el) => {
if (el) (el as HTMLElement).innerHTML = settings.sidebarTitle;
});
(async () => {
if (this._sidebarTitleSubscription) {
this._sidebarTitleSubscription();
}
this._sidebarTitleSubscription = undefined;
this._sidebarTitleSubscription =
await this.connection.subscribeMessage(this._updateSidebarTitle, {
type: "render_template",
template: settings.sidebarTitle,
variables: {},
});
})();
}
// Hide header
@@ -115,6 +122,15 @@ export const AutoSettingsMixin = (SuperClass) => {
}
}
_updateSidebarTitle({ result }) {
selectTree(
document,
"home-assistant $ home-assistant-main $ app-drawer-layout app-drawer ha-sidebar $ .title"
).then((el) => {
if (el) (el as HTMLElement).innerHTML = result;
});
}
get _currentFavicon() {
const link: any = document.head.querySelector("link[rel~='icon']");
return link?.href;