Skip to content

Commit 730e9b1

Browse files
zsarnettballoob
andauthored
When refreshing updates, notify user when finished (home-assistant#11464)
Co-authored-by: Paulus Schoutsen <[email protected]>
1 parent 69ff8dd commit 730e9b1

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/panels/config/dashboard/ha-config-dashboard.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ import "@material/mwc-list/mwc-list-item";
33
import type { ActionDetail } from "@material/mwc-list";
44
import "@polymer/app-layout/app-header/app-header";
55
import "@polymer/app-layout/app-toolbar/app-toolbar";
6-
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
6+
import {
7+
css,
8+
CSSResultGroup,
9+
html,
10+
LitElement,
11+
PropertyValues,
12+
TemplateResult,
13+
} from "lit";
714
import { customElement, property } from "lit/decorators";
815
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
916
import "../../../components/ha-card";
@@ -26,6 +33,7 @@ import "./ha-config-navigation";
2633
import "./ha-config-updates";
2734
import { fireEvent } from "../../../common/dom/fire_event";
2835
import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box";
36+
import { showToast } from "../../../util/toast";
2937

3038
@customElement("ha-config-dashboard")
3139
class HaConfigDashboard extends LitElement {
@@ -43,6 +51,8 @@ class HaConfigDashboard extends LitElement {
4351

4452
@property() public showAdvanced!: boolean;
4553

54+
private _notifyUpdates = false;
55+
4656
protected render(): TemplateResult {
4757
return html`
4858
<ha-app-layout>
@@ -129,6 +139,26 @@ class HaConfigDashboard extends LitElement {
129139
`;
130140
}
131141

142+
protected override updated(changedProps: PropertyValues): void {
143+
super.updated(changedProps);
144+
145+
if (!changedProps.has("supervisorUpdates") || !this._notifyUpdates) {
146+
return;
147+
}
148+
this._notifyUpdates = false;
149+
if (this.supervisorUpdates?.length) {
150+
showToast(this, {
151+
message: this.hass.localize(
152+
"ui.panel.config.updates.updates_refreshed"
153+
),
154+
});
155+
} else {
156+
showToast(this, {
157+
message: this.hass.localize("ui.panel.config.updates.no_new_updates"),
158+
});
159+
}
160+
}
161+
132162
private _showQuickBar(): void {
133163
showQuickBar(this, {
134164
commandMode: true,
@@ -140,6 +170,7 @@ class HaConfigDashboard extends LitElement {
140170
switch (ev.detail.index) {
141171
case 0:
142172
if (isComponentLoaded(this.hass, "hassio")) {
173+
this._notifyUpdates = true;
143174
await refreshSupervisorAvailableUpdates(this.hass);
144175
fireEvent(this, "ha-refresh-supervisor");
145176
return;

src/translations/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,8 @@
10111011
"description": "You need to run the Home Assistant operating system to be able to check and install updates from the Home Assistant user interface."
10121012
},
10131013
"check_updates": "Check for updates",
1014+
"no_new_updates": "No new updates found",
1015+
"updates_refreshed": "Updates refreshed",
10141016
"title": "{count} {count, plural,\n one {update}\n other {updates}\n}",
10151017
"unable_to_fetch": "Unable to load updates",
10161018
"version_available": "Version {version_available} is available",

0 commit comments

Comments
 (0)