mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Show error screen when connection fails (#11030)
This commit is contained in:
parent
322d965539
commit
3e062ba673
@ -34,8 +34,6 @@ const panelUrl = (path: string) => {
|
||||
export class HomeAssistantAppEl extends QuickBarMixin(HassElement) {
|
||||
@state() private _route: Route;
|
||||
|
||||
@state() private _error = false;
|
||||
|
||||
private _panelUrl: string;
|
||||
|
||||
private _haVersion?: string;
|
||||
@ -44,8 +42,6 @@ export class HomeAssistantAppEl extends QuickBarMixin(HassElement) {
|
||||
|
||||
private _visiblePromiseResolve?: () => void;
|
||||
|
||||
private _visibleLaunchScreen = true;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
const path = curPath();
|
||||
@ -62,8 +58,7 @@ export class HomeAssistantAppEl extends QuickBarMixin(HassElement) {
|
||||
this._panelUrl = panelUrl(path);
|
||||
}
|
||||
|
||||
protected render() {
|
||||
if (this._isHassComplete() && this.hass) {
|
||||
protected renderHass() {
|
||||
return html`
|
||||
<home-assistant-main
|
||||
.hass=${this.hass}
|
||||
@ -72,17 +67,13 @@ export class HomeAssistantAppEl extends QuickBarMixin(HassElement) {
|
||||
`;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
update(changedProps) {
|
||||
super.update(changedProps);
|
||||
|
||||
// Remove launch screen if main gui is loaded
|
||||
if (this._isHassComplete() && this._visibleLaunchScreen) {
|
||||
this._visibleLaunchScreen = false;
|
||||
if (this.hass?.states && this.hass.config && this.hass.services) {
|
||||
this.render = this.renderHass;
|
||||
this.update = super.update;
|
||||
removeLaunchScreen();
|
||||
}
|
||||
super.update(changedProps);
|
||||
}
|
||||
|
||||
protected firstUpdated(changedProps) {
|
||||
@ -129,10 +120,9 @@ export class HomeAssistantAppEl extends QuickBarMixin(HassElement) {
|
||||
});
|
||||
|
||||
// Render launch screen info box (loading data / error message)
|
||||
if (!this._isHassComplete() && this._visibleLaunchScreen) {
|
||||
renderLaunchScreenInfoBox(
|
||||
html`<ha-init-page .error=${this._error}></ha-init-page>`
|
||||
);
|
||||
// if Home Assistant is not loaded yet.
|
||||
if (this.render !== this.renderHass) {
|
||||
this._renderInitInfo(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,7 +178,7 @@ export class HomeAssistantAppEl extends QuickBarMixin(HassElement) {
|
||||
if (window.hassConnection) {
|
||||
result = await window.hassConnection;
|
||||
} else {
|
||||
// In the edge case that
|
||||
// In the edge case that core.ts loads before app.ts
|
||||
result = await new Promise((resolve) => {
|
||||
window.hassConnectionReady = resolve;
|
||||
});
|
||||
@ -198,7 +188,7 @@ export class HomeAssistantAppEl extends QuickBarMixin(HassElement) {
|
||||
this._haVersion = conn.haVersion;
|
||||
this.initializeHass(auth, conn);
|
||||
} catch (err: any) {
|
||||
this._error = true;
|
||||
this._renderInitInfo(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,12 +245,10 @@ export class HomeAssistantAppEl extends QuickBarMixin(HassElement) {
|
||||
}
|
||||
}
|
||||
|
||||
private _isHassComplete(): boolean {
|
||||
if (this.hass?.states && this.hass.config && this.hass.services) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
private _renderInitInfo(error: boolean) {
|
||||
renderLaunchScreenInfoBox(
|
||||
html`<ha-init-page .error=${error}></ha-init-page>`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,9 @@ export const removeLaunchScreen = () => {
|
||||
}
|
||||
};
|
||||
|
||||
export const renderLaunchScreenInfoBox = (element: TemplateResult) => {
|
||||
export const renderLaunchScreenInfoBox = (content: TemplateResult) => {
|
||||
const infoBoxElement = document.getElementById("ha-launch-screen-info-box");
|
||||
if (infoBoxElement) {
|
||||
render(element, infoBoxElement);
|
||||
render(content, infoBoxElement);
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user