Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 32 additions & 11 deletions hassio/src/ingress-view/hassio-ingress-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,22 @@ class HassioIngressView extends LitElement {

private _fetchDataTimeout?: number;

private _messageListener = (ev: MessageEvent) => {
if (this._addon?.webui_ha_aware && ev.data?.type === "toggle-sidebar") {
this._toggleMenu();
}
};

public connectedCallback() {
super.connectedCallback();
window.addEventListener("message", this._messageListener);
}

public disconnectedCallback() {
super.disconnectedCallback();

window.removeEventListener("message", this._messageListener);

if (this._sessionKeepAlive) {
clearInterval(this._sessionKeepAlive);
this._sessionKeepAlive = undefined;
Expand Down Expand Up @@ -83,17 +96,25 @@ class HassioIngressView extends LitElement {
</hass-subpage>`;
}

return html`${this.narrow || this.hass.dockedSidebar === "always_hidden"
? html`<div class="header">
<ha-icon-button
.label=${this.hass.localize("ui.sidebar.sidebar_toggle")}
.path=${mdiMenu}
@click=${this._toggleMenu}
></ha-icon-button>
<div class="main-title">${this._addon.name}</div>
</div>
${iframe}`
: iframe}`;
// If webui_ha_aware is true, or if narrow or sidebar is always hidden,
// don't render the header and just render the iframe
if (
this._addon.webui_ha_aware ||
this.narrow ||
this.hass.dockedSidebar === "always_hidden"
) {
return iframe;
}

return html`<div class="header">
<ha-icon-button
.label=${this.hass.localize("ui.sidebar.sidebar_toggle")}
.path=${mdiMenu}
@click=${this._toggleMenu}
></ha-icon-button>
<div class="main-title">${this._addon.name}</div>
</div>
${iframe}`;
}

protected async firstUpdated(): Promise<void> {
Expand Down
1 change: 1 addition & 0 deletions src/data/hassio/addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export interface HassioAddonDetails extends HassioAddonInfo {
translations: Record<string, AddonTranslations>;
watchdog: null | boolean;
webui: null | string;
webui_ha_aware?: boolean;
}

export interface HassioAddonsInfo {
Expand Down
Loading