When refreshing updates, notify user when finished (#11464)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
Zack Barett 2022-01-28 13:03:45 -06:00 committed by GitHub
parent 69ff8dd0c4
commit 730e9b144d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 1 deletions

View File

@ -3,7 +3,14 @@ import "@material/mwc-list/mwc-list-item";
import type { ActionDetail } from "@material/mwc-list";
import "@polymer/app-layout/app-header/app-header";
import "@polymer/app-layout/app-toolbar/app-toolbar";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import {
css,
CSSResultGroup,
html,
LitElement,
PropertyValues,
TemplateResult,
} from "lit";
import { customElement, property } from "lit/decorators";
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
import "../../../components/ha-card";
@ -26,6 +33,7 @@ import "./ha-config-navigation";
import "./ha-config-updates";
import { fireEvent } from "../../../common/dom/fire_event";
import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box";
import { showToast } from "../../../util/toast";
@customElement("ha-config-dashboard")
class HaConfigDashboard extends LitElement {
@ -43,6 +51,8 @@ class HaConfigDashboard extends LitElement {
@property() public showAdvanced!: boolean;
private _notifyUpdates = false;
protected render(): TemplateResult {
return html`
<ha-app-layout>
@ -129,6 +139,26 @@ class HaConfigDashboard extends LitElement {
`;
}
protected override updated(changedProps: PropertyValues): void {
super.updated(changedProps);
if (!changedProps.has("supervisorUpdates") || !this._notifyUpdates) {
return;
}
this._notifyUpdates = false;
if (this.supervisorUpdates?.length) {
showToast(this, {
message: this.hass.localize(
"ui.panel.config.updates.updates_refreshed"
),
});
} else {
showToast(this, {
message: this.hass.localize("ui.panel.config.updates.no_new_updates"),
});
}
}
private _showQuickBar(): void {
showQuickBar(this, {
commandMode: true,
@ -140,6 +170,7 @@ class HaConfigDashboard extends LitElement {
switch (ev.detail.index) {
case 0:
if (isComponentLoaded(this.hass, "hassio")) {
this._notifyUpdates = true;
await refreshSupervisorAvailableUpdates(this.hass);
fireEvent(this, "ha-refresh-supervisor");
return;

View File

@ -1011,6 +1011,8 @@
"description": "You need to run the Home Assistant operating system to be able to check and install updates from the Home Assistant user interface."
},
"check_updates": "Check for updates",
"no_new_updates": "No new updates found",
"updates_refreshed": "Updates refreshed",
"title": "{count} {count, plural,\n one {update}\n other {updates}\n}",
"unable_to_fetch": "Unable to load updates",
"version_available": "Version {version_available} is available",