mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Wait for cloud and backup in onboarding (#24997)
This commit is contained in:
parent
0541270695
commit
929a0b9cd4
@ -128,3 +128,11 @@ export const forgotPasswordHaCloud = async (email: string) =>
|
||||
body: JSON.stringify({ email }),
|
||||
})
|
||||
);
|
||||
|
||||
export const waitForIntegration = (domain: string) =>
|
||||
handleFetchPromise<{ integration_loaded: boolean }>(
|
||||
fetch("/api/onboarding/integration/wait", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ domain }),
|
||||
})
|
||||
);
|
||||
|
@ -15,7 +15,11 @@ import {
|
||||
} from "../data/backup_onboarding";
|
||||
import { CLOUD_AGENT, type BackupContentExtended } from "../data/backup";
|
||||
import { storage } from "../common/decorators/storage";
|
||||
import { fetchHaCloudStatus, signOutHaCloud } from "../data/onboarding";
|
||||
import {
|
||||
fetchHaCloudStatus,
|
||||
signOutHaCloud,
|
||||
waitForIntegration,
|
||||
} from "../data/onboarding";
|
||||
import type { CloudStatus } from "../data/cloud";
|
||||
import { showToast } from "../util/toast";
|
||||
|
||||
@ -57,8 +61,13 @@ class OnboardingRestoreBackup extends LitElement {
|
||||
})
|
||||
private _restoreRunning?: boolean;
|
||||
|
||||
private _loadedIntegrations = new Set<string>();
|
||||
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
${this._error && this._view !== "restore"
|
||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||
: nothing}
|
||||
${this._view === "loading"
|
||||
? html`<onboarding-loading></onboarding-loading>`
|
||||
: this._view === "upload"
|
||||
@ -125,6 +134,14 @@ class OnboardingRestoreBackup extends LitElement {
|
||||
private async _loadBackupInfo() {
|
||||
let onboardingInfo: BackupOnboardingConfig;
|
||||
try {
|
||||
if (!this._loadedIntegrations.has("backup")) {
|
||||
if ((await waitForIntegration("backup")).integration_loaded) {
|
||||
this._loadedIntegrations.add("backup");
|
||||
} else {
|
||||
this._error = "Backup integration not loaded";
|
||||
return;
|
||||
}
|
||||
}
|
||||
onboardingInfo = await fetchBackupOnboardingInfo();
|
||||
} catch (err: any) {
|
||||
if (this._restoreRunning) {
|
||||
@ -169,6 +186,14 @@ class OnboardingRestoreBackup extends LitElement {
|
||||
|
||||
if (this.mode === "cloud") {
|
||||
try {
|
||||
if (!this._loadedIntegrations.has("cloud")) {
|
||||
if ((await waitForIntegration("cloud")).integration_loaded) {
|
||||
this._loadedIntegrations.add("cloud");
|
||||
} else {
|
||||
this._error = "Cloud integration not loaded";
|
||||
return;
|
||||
}
|
||||
}
|
||||
this._cloudStatus = await fetchHaCloudStatus();
|
||||
} catch (err: any) {
|
||||
this._error = err?.message || "Cannot get Home Assistant Cloud status";
|
||||
|
Loading…
x
Reference in New Issue
Block a user