Show menu button when Hassio supervisor UI runs on old HA (#3347)

This commit is contained in:
Paulus Schoutsen 2019-07-10 10:10:56 -07:00 committed by GitHub
parent 14a430a059
commit 5d8e34e8be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -21,6 +21,7 @@ class HaMenuButton extends LitElement {
@property() public narrow!: boolean;
@property() public hass!: HomeAssistant;
@property() private _hasNotifications = false;
private _alwaysVisible = false;
private _attachNotifOnConnect = false;
private _unsubNotifications?: UnsubscribeFunc;
@ -62,6 +63,18 @@ class HaMenuButton extends LitElement {
`;
}
protected firstUpdated(changedProps) {
super.firstUpdated(changedProps);
if (!this.hassio) {
return;
}
// This component is used on Hass.io too, but Hass.io might run the UI
// on older frontends too, that don't have an always visible menu button
// in the sidebar.
this._alwaysVisible =
(Number((window.parent as any).frontendVersion) || 0) >= 20190710;
}
protected updated(changedProps) {
super.updated(changedProps);
@ -69,7 +82,8 @@ class HaMenuButton extends LitElement {
return;
}
this.style.visibility = this.narrow ? "initial" : "hidden";
this.style.visibility =
this.narrow || this._alwaysVisible ? "initial" : "hidden";
if (!this.narrow) {
this._hasNotifications = false;

View File

@ -16,3 +16,5 @@ import "../layouts/home-assistant";
setPassiveTouchGestures(true);
/* LastPass createElement workaround. See #428 */
document.createElement = Document.prototype.createElement;
(window as any).frontendVersion = __VERSION__;