Move deleting backups to WS (#15773)

This commit is contained in:
Joakim Sørensen 2023-03-09 11:32:52 +01:00 committed by GitHub
parent 77d395b0c9
commit 47cfc3d27c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 17 deletions

View File

@ -16,6 +16,7 @@ import { getSignedPath } from "../../../../src/data/auth";
import {
fetchHassioBackupInfo,
HassioBackupDetail,
removeBackup,
} from "../../../../src/data/hassio/backup";
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
import {
@ -286,24 +287,15 @@ class HassioBackupDialog
return;
}
this.hass!.callApi(
atLeastVersion(this.hass!.config.version, 2021, 9) ? "DELETE" : "POST",
`hassio/${
atLeastVersion(this.hass!.config.version, 2021, 9)
? `backups/${this._backup!.slug}`
: `snapshots/${this._backup!.slug}/remove`
}`
).then(
() => {
if (this._dialogParams!.onDelete) {
this._dialogParams!.onDelete();
}
this.closeDialog();
},
(error) => {
this._error = error.body.message;
try {
await removeBackup(this.hass!, this._backup!.slug);
if (this._dialogParams!.onDelete) {
this._dialogParams!.onDelete();
}
);
this.closeDialog();
} catch (err: any) {
this._error = err.body.message;
}
}
private async _downloadClicked() {