mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Make sure we load data in update card (#11516)
This commit is contained in:
parent
866a57cde4
commit
5e80a2b465
@ -33,8 +33,12 @@ import {
|
|||||||
extractApiErrorMessage,
|
extractApiErrorMessage,
|
||||||
ignoreSupervisorError,
|
ignoreSupervisorError,
|
||||||
} from "../../../src/data/hassio/common";
|
} from "../../../src/data/hassio/common";
|
||||||
import { updateOS } from "../../../src/data/hassio/host";
|
import { fetchHassioHassOsInfo, updateOS } from "../../../src/data/hassio/host";
|
||||||
import { updateSupervisor } from "../../../src/data/hassio/supervisor";
|
import {
|
||||||
|
fetchHassioHomeAssistantInfo,
|
||||||
|
fetchHassioSupervisorInfo,
|
||||||
|
updateSupervisor,
|
||||||
|
} from "../../../src/data/hassio/supervisor";
|
||||||
import { updateCore } from "../../../src/data/supervisor/core";
|
import { updateCore } from "../../../src/data/supervisor/core";
|
||||||
import { StoreAddon } from "../../../src/data/supervisor/store";
|
import { StoreAddon } from "../../../src/data/supervisor/store";
|
||||||
import { Supervisor } from "../../../src/data/supervisor/supervisor";
|
import { Supervisor } from "../../../src/data/supervisor/supervisor";
|
||||||
@ -212,11 +216,22 @@ class UpdateAvailableCard extends LitElement {
|
|||||||
: "addon";
|
: "addon";
|
||||||
this._updateType = updateType as updateType;
|
this._updateType = updateType as updateType;
|
||||||
|
|
||||||
if (updateType === "addon") {
|
switch (updateType) {
|
||||||
if (!this.addonSlug) {
|
case "addon":
|
||||||
this.addonSlug = pathPart;
|
if (!this.addonSlug) {
|
||||||
}
|
this.addonSlug = pathPart;
|
||||||
this._loadAddonData();
|
}
|
||||||
|
this._loadAddonData();
|
||||||
|
break;
|
||||||
|
case "core":
|
||||||
|
this._loadCoreData();
|
||||||
|
break;
|
||||||
|
case "supervisor":
|
||||||
|
this._loadSupervisorData();
|
||||||
|
break;
|
||||||
|
case "os":
|
||||||
|
this._loadOsData();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,6 +323,42 @@ class UpdateAvailableCard extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _loadSupervisorData() {
|
||||||
|
try {
|
||||||
|
const supervisor = await fetchHassioSupervisorInfo(this.hass);
|
||||||
|
fireEvent(this, "supervisor-update", { supervisor });
|
||||||
|
} catch (err) {
|
||||||
|
showAlertDialog(this, {
|
||||||
|
title: this._updateType,
|
||||||
|
text: extractApiErrorMessage(err),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async _loadCoreData() {
|
||||||
|
try {
|
||||||
|
const core = await fetchHassioHomeAssistantInfo(this.hass);
|
||||||
|
fireEvent(this, "supervisor-update", { core });
|
||||||
|
} catch (err) {
|
||||||
|
showAlertDialog(this, {
|
||||||
|
title: this._updateType,
|
||||||
|
text: extractApiErrorMessage(err),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async _loadOsData() {
|
||||||
|
try {
|
||||||
|
const os = await fetchHassioHassOsInfo(this.hass);
|
||||||
|
fireEvent(this, "supervisor-update", { os });
|
||||||
|
} catch (err) {
|
||||||
|
showAlertDialog(this, {
|
||||||
|
title: this._updateType,
|
||||||
|
text: extractApiErrorMessage(err),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async _update() {
|
private async _update() {
|
||||||
this._error = undefined;
|
this._error = undefined;
|
||||||
this._updating = true;
|
this._updating = true;
|
||||||
|
@ -82,7 +82,7 @@ async function processEvent(
|
|||||||
event: SupervisorEvent,
|
event: SupervisorEvent,
|
||||||
key: string
|
key: string
|
||||||
) {
|
) {
|
||||||
if (event.event !== "supervisor-update" || event.update_key !== key) {
|
if (event.event !== "supervisor_update" || event.update_key !== key) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user