Skip to content

Commit

Permalink
Actually fix it
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed May 23, 2024
1 parent 97200c6 commit ec579e7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/components/dialogs/hacs-download-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export class HacsDonwloadDialog extends LitElement {

@state() _dialogParams?: HacsDownloadDialogParams;

@state() _selectedVersion?: string;

public async showDialog(dialogParams: HacsDownloadDialogParams): Promise<void> {
this._dialogParams = dialogParams;
this._waiting = false;
Expand All @@ -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) => {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 || {
Expand Down

0 comments on commit ec579e7

Please sign in to comment.