From ec579e7e1df6b70b2c98a9dfbd8ea8f822bb75b4 Mon Sep 17 00:00:00 2001 From: ludeeus Date: Thu, 23 May 2024 08:13:58 +0000 Subject: [PATCH] Actually fix it --- src/components/dialogs/hacs-download-dialog.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/dialogs/hacs-download-dialog.ts b/src/components/dialogs/hacs-download-dialog.ts index 48612cfc..c25a2acb 100644 --- a/src/components/dialogs/hacs-download-dialog.ts +++ b/src/components/dialogs/hacs-download-dialog.ts @@ -41,6 +41,8 @@ export class HacsDonwloadDialog extends LitElement { @state() _dialogParams?: HacsDownloadDialogParams; + @state() _selectedVersion?: string; + public async showDialog(dialogParams: HacsDownloadDialogParams): Promise { this._dialogParams = dialogParams; this._waiting = false; @@ -50,6 +52,10 @@ export class HacsDonwloadDialog extends LitElement { await this._fetchRepository(); } + if (this._repository && this._repository.version_or_commit !== "commit") { + this._selectedVersion = this._repository.available_version; + } + websocketSubscription( this.hass, (data) => { @@ -91,10 +97,6 @@ export class HacsDonwloadDialog extends LitElement { } const installPath = this._getInstallPath(this._repository); - const selectedVersion = - this._repository.selected_tag || - this._repository.available_version || - this._repository.default_branch; const donwloadRepositorySchema: HaFormSchema[] = [ { name: "beta", @@ -131,7 +133,7 @@ export class HacsDonwloadDialog extends LitElement { .data=${this._repository.version_or_commit === "version" ? { beta: this._repository.beta, - version: selectedVersion, + version: this._selectedVersion, } : {}} .schema=${donwloadRepositorySchema} @@ -225,6 +227,7 @@ export class HacsDonwloadDialog extends LitElement { this._dialogParams!.repositoryId, ev.detail.value.version, ); + this._selectedVersion = ev.detail.value.version; } if (updateNeeded) { await this._fetchRepository(); @@ -264,7 +267,7 @@ export class HacsDonwloadDialog extends LitElement { await repositoryDownloadVersion( this.hass, String(this._repository.id), - this._repository?.version_or_commit !== "commit" ? selectedVersion : undefined, + this._repository?.version_or_commit !== "commit" ? this._selectedVersion : undefined, ); } catch (err: any) { this._error = err || {