mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
cast allow empty view, pick first (#19739)
This commit is contained in:
parent
8624853ec4
commit
045ff7a45e
@ -17,7 +17,7 @@ class HcLovelace extends LitElement {
|
|||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
public lovelaceConfig!: LovelaceConfig;
|
public lovelaceConfig!: LovelaceConfig;
|
||||||
|
|
||||||
@property() public viewPath?: string | number;
|
@property() public viewPath?: string | number | null;
|
||||||
|
|
||||||
@property() public urlPath: string | null = null;
|
@property() public urlPath: string | null = null;
|
||||||
|
|
||||||
@ -93,6 +93,9 @@ class HcLovelace extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private get _viewIndex() {
|
private get _viewIndex() {
|
||||||
|
if (this.viewPath === null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
const selectedView = this.viewPath;
|
const selectedView = this.viewPath;
|
||||||
const selectedViewInt = parseInt(selectedView as string, 10);
|
const selectedViewInt = parseInt(selectedView as string, 10);
|
||||||
for (let i = 0; i < this.lovelaceConfig.views.length; i++) {
|
for (let i = 0; i < this.lovelaceConfig.views.length; i++) {
|
||||||
|
@ -51,10 +51,10 @@ export class HcMain extends HassElement {
|
|||||||
|
|
||||||
@state() private _lovelacePath: string | number | null = null;
|
@state() private _lovelacePath: string | number | null = null;
|
||||||
|
|
||||||
@state() private _error?: string;
|
|
||||||
|
|
||||||
@state() private _urlPath?: string | null;
|
@state() private _urlPath?: string | null;
|
||||||
|
|
||||||
|
@state() private _error?: string;
|
||||||
|
|
||||||
private _hassUUID?: string;
|
private _hassUUID?: string;
|
||||||
|
|
||||||
private _unsubLovelace?: UnsubscribeFunc;
|
private _unsubLovelace?: UnsubscribeFunc;
|
||||||
@ -81,7 +81,7 @@ export class HcMain extends HassElement {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
!this._lovelaceConfig ||
|
!this._lovelaceConfig ||
|
||||||
this._lovelacePath === null ||
|
this._urlPath === undefined ||
|
||||||
// Guard against part of HA not being loaded yet.
|
// Guard against part of HA not being loaded yet.
|
||||||
!this.hass ||
|
!this.hass ||
|
||||||
!this.hass.states ||
|
!this.hass.states ||
|
||||||
@ -99,8 +99,8 @@ export class HcMain extends HassElement {
|
|||||||
<hc-lovelace
|
<hc-lovelace
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.lovelaceConfig=${this._lovelaceConfig}
|
.lovelaceConfig=${this._lovelaceConfig}
|
||||||
.viewPath=${this._lovelacePath}
|
|
||||||
.urlPath=${this._urlPath}
|
.urlPath=${this._urlPath}
|
||||||
|
.viewPath=${this._lovelacePath}
|
||||||
@config-refresh=${this._generateDefaultLovelaceConfig}
|
@config-refresh=${this._generateDefaultLovelaceConfig}
|
||||||
></hc-lovelace>
|
></hc-lovelace>
|
||||||
`;
|
`;
|
||||||
@ -226,9 +226,9 @@ export class HcMain extends HassElement {
|
|||||||
this.initializeHass(auth, connection);
|
this.initializeHass(auth, connection);
|
||||||
if (this._hassUUID !== msg.hassUUID) {
|
if (this._hassUUID !== msg.hassUUID) {
|
||||||
this._hassUUID = msg.hassUUID;
|
this._hassUUID = msg.hassUUID;
|
||||||
this._lovelacePath = null;
|
|
||||||
this._urlPath = undefined;
|
|
||||||
this._lovelaceConfig = undefined;
|
this._lovelaceConfig = undefined;
|
||||||
|
this._urlPath = undefined;
|
||||||
|
this._lovelacePath = null;
|
||||||
if (this._unsubLovelace) {
|
if (this._unsubLovelace) {
|
||||||
this._unsubLovelace();
|
this._unsubLovelace();
|
||||||
this._unsubLovelace = undefined;
|
this._unsubLovelace = undefined;
|
||||||
@ -285,7 +285,7 @@ export class HcMain extends HassElement {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
this._urlPath = "energy";
|
this._urlPath = "energy";
|
||||||
this._lovelacePath = 0;
|
this._lovelacePath = null;
|
||||||
this._sendStatus();
|
this._sendStatus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user