Skip to content

Commit 5e62989

Browse files
committed
Polish
1 parent a146329 commit 5e62989

5 files changed

Lines changed: 24 additions & 35 deletions

File tree

src/data/backup.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,20 @@ export const updateBackupConfig = (
189189
config: BackupMutableConfig
190190
) => hass.callWS({ type: "backup/config/update", ...config });
191191

192+
export const saveBackupConfig = (hass: HomeAssistant, config: BackupConfig) =>
193+
updateBackupConfig(hass, {
194+
create_backup: {
195+
agent_ids: config.create_backup.agent_ids,
196+
include_folders: config.create_backup.include_folders ?? [],
197+
include_database: config.create_backup.include_database,
198+
include_addons: config.create_backup.include_addons ?? [],
199+
include_all_addons: config.create_backup.include_all_addons,
200+
password: config.create_backup.password,
201+
},
202+
retention: config.retention,
203+
schedule: config.schedule,
204+
});
205+
192206
export const getBackupDownloadUrl = (
193207
id: string,
194208
agentId: string,

src/panels/config/backup/components/overview/ha-backup-overview-app-update-backup.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { mdiPuzzle } from "@mdi/js";
22
import type { CSSResultGroup } from "lit";
33
import { css, html, LitElement } from "lit";
44
import { customElement, property, state } from "lit/decorators";
5-
import { isComponentLoaded } from "../../../../../common/config/is_component_loaded";
65
import "../../../../../components/ha-card";
76
import "../../../../../components/ha-icon-next";
87
import "../../../../../components/ha-md-list";
@@ -26,11 +25,12 @@ class HaBackupOverviewAppUpdateBackup extends LitElement {
2625
}
2726

2827
private async _fetchSupervisorUpdateConfig() {
29-
if (!isComponentLoaded(this.hass.config, "hassio")) {
30-
return;
28+
try {
29+
this._supervisorUpdateConfig = await getSupervisorUpdateConfig(this.hass);
30+
} catch (err) {
31+
// eslint-disable-next-line no-console
32+
console.error(err);
3133
}
32-
33-
this._supervisorUpdateConfig = await getSupervisorUpdateConfig(this.hass);
3434
}
3535

3636
private _appUpdateBackupDescription() {

src/panels/config/backup/ha-config-backup-app-update-backups.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { css, html, LitElement, nothing } from "lit";
22
import type { PropertyValues } from "lit";
33
import { customElement, property, state } from "lit/decorators";
4+
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
45
import { debounce } from "../../../common/util/debounce";
56
import "../../../components/ha-alert";
67
import "../../../components/ha-card";
7-
import type { CloudStatus } from "../../../data/cloud";
8-
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
98
import {
109
getSupervisorUpdateConfig,
1110
updateSupervisorUpdateConfig,
@@ -19,8 +18,6 @@ import "./components/config/ha-backup-config-addon";
1918
class HaConfigBackupAppUpdateBackups extends LitElement {
2019
@property({ attribute: false }) public hass!: HomeAssistant;
2120

22-
@property({ attribute: false }) public cloudStatus?: CloudStatus;
23-
2421
@property({ type: Boolean }) public narrow = false;
2522

2623
@state() private _supervisorUpdateConfig?: SupervisorUpdateConfig;

src/panels/config/backup/ha-config-backup-overview.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
computeBackupAgentName,
2525
generateBackup,
2626
generateBackupWithAutomaticSettings,
27-
updateBackupConfig,
27+
saveBackupConfig,
2828
} from "../../../data/backup";
2929
import type { ManagerStateEvent } from "../../../data/backup_manager";
3030
import type { CloudStatus } from "../../../data/cloud";
@@ -100,18 +100,7 @@ class HaConfigBackupOverview extends LitElement {
100100
return;
101101
}
102102

103-
await updateBackupConfig(this.hass, {
104-
create_backup: {
105-
agent_ids: this.config.create_backup.agent_ids,
106-
include_folders: this.config.create_backup.include_folders ?? [],
107-
include_database: this.config.create_backup.include_database,
108-
include_addons: this.config.create_backup.include_addons ?? [],
109-
include_all_addons: this.config.create_backup.include_all_addons,
110-
password: this.config.create_backup.password,
111-
},
112-
retention: this.config.retention,
113-
schedule: this.config.schedule,
114-
});
103+
await saveBackupConfig(this.hass, this.config);
115104

116105
fireEvent(this, "ha-refresh-backup-config");
117106
}

src/panels/config/backup/ha-config-backup-settings.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import "../../../components/ha-icon-button";
1616
import "../../../components/ha-icon-next";
1717
import "../../../components/ha-svg-icon";
1818
import type { BackupAgent, BackupConfig } from "../../../data/backup";
19-
import { updateBackupConfig } from "../../../data/backup";
19+
import { saveBackupConfig } from "../../../data/backup";
2020
import type { CloudStatus } from "../../../data/cloud";
2121
import {
2222
getSupervisorUpdateConfig,
@@ -414,18 +414,7 @@ class HaConfigBackupSettings extends LitElement {
414414
private _debounceSave = debounce(() => this._save(), 500);
415415

416416
private async _save() {
417-
await updateBackupConfig(this.hass, {
418-
create_backup: {
419-
agent_ids: this._config!.create_backup.agent_ids,
420-
include_folders: this._config!.create_backup.include_folders ?? [],
421-
include_database: this._config!.create_backup.include_database,
422-
include_addons: this._config!.create_backup.include_addons ?? [],
423-
include_all_addons: this._config!.create_backup.include_all_addons,
424-
password: this._config!.create_backup.password,
425-
},
426-
retention: this._config!.retention,
427-
schedule: this._config!.schedule,
428-
});
417+
await saveBackupConfig(this.hass, this._config!);
429418
fireEvent(this, "ha-refresh-backup-config");
430419
}
431420

0 commit comments

Comments
 (0)