diff --git a/pyproject.toml b/pyproject.toml index c7a4e50fc4..59884f9957 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "home-assistant-frontend" -version = "20250531.2" +version = "20250531.3" license = "Apache-2.0" license-files = ["LICENSE*"] description = "The Home Assistant frontend" diff --git a/src/data/backup.ts b/src/data/backup.ts index 12261eb810..fd0324a229 100644 --- a/src/data/backup.ts +++ b/src/data/backup.ts @@ -339,7 +339,7 @@ export const computeBackupSize = (backup: BackupContent) => export type BackupType = "automatic" | "manual" | "addon_update"; -const BACKUP_TYPE_ORDER: BackupType[] = ["automatic", "manual", "addon_update"]; +const BACKUP_TYPE_ORDER: BackupType[] = ["automatic", "addon_update", "manual"]; export const getBackupTypes = memoize((isHassio: boolean) => isHassio diff --git a/src/panels/config/devices/ha-config-device-page.ts b/src/panels/config/devices/ha-config-device-page.ts index e396c7072b..44530ab333 100644 --- a/src/panels/config/devices/ha-config-device-page.ts +++ b/src/panels/config/devices/ha-config-device-page.ts @@ -127,16 +127,15 @@ export class HaConfigDevicePage extends LitElement { @state() private _related?: RelatedResult; - // If a number, it's the request ID so we make sure we don't show older info - @state() private _diagnosticDownloadLinks?: number | DeviceAction[]; + @state() private _diagnosticDownloadLinks: DeviceAction[] = []; - @state() private _deleteButtons?: DeviceAction[]; + @state() private _deleteButtons: DeviceAction[] = []; - @state() private _deviceActions?: DeviceAction[]; + @state() private _deviceActions: DeviceAction[] = []; - @state() private _deviceAlerts?: DeviceAlert[]; + @state() private _deviceAlerts: DeviceAlert[] = []; - private _deviceAlertsTimeout?: number; + private _deviceAlertsActionsTimeout?: number; @state() @consume({ context: fullEntitiesContext, subscribe: true }) @@ -255,42 +254,19 @@ export class HaConfigDevicePage extends LitElement { public willUpdate(changedProps) { super.willUpdate(changedProps); - if ( - changedProps.has("deviceId") || - changedProps.has("devices") || - changedProps.has("entries") - ) { - this._diagnosticDownloadLinks = undefined; - this._deleteButtons = undefined; - this._deviceActions = undefined; - this._deviceAlerts = undefined; + if (changedProps.has("deviceId") || changedProps.has("entries")) { + this._deviceActions = []; + this._deviceAlerts = []; + this._deleteButtons = []; + this._diagnosticDownloadLinks = []; + this._fetchData(); } - - if ( - (this._diagnosticDownloadLinks && - this._deleteButtons && - this._deviceActions && - this._deviceAlerts) || - !this.deviceId || - !this.entries - ) { - return; - } - - this._diagnosticDownloadLinks = Math.random(); - this._deleteButtons = []; // To prevent re-rendering if no delete buttons - this._deviceActions = []; - this._deviceAlerts = []; - this._getDiagnosticButtons(this._diagnosticDownloadLinks); - this._getDeleteActions(); - this._getDeviceActions(); - clearTimeout(this._deviceAlertsTimeout); - this._getDeviceAlerts(); } protected firstUpdated(changedProps) { super.firstUpdated(changedProps); loadDeviceRegistryDetailDialog(); + this._fetchData(); } protected updated(changedProps) { @@ -302,7 +278,7 @@ export class HaConfigDevicePage extends LitElement { public disconnectedCallback() { super.disconnectedCallback(); - clearTimeout(this._deviceAlertsTimeout); + clearTimeout(this._deviceAlertsActionsTimeout); } protected render() { @@ -909,7 +885,18 @@ export class HaConfigDevicePage extends LitElement { `; } - private async _getDiagnosticButtons(requestId: number): Promise { + private _fetchData() { + if (this.deviceId && this.entries.length) { + this._getDiagnosticButtons(); + this._getDeleteActions(); + clearTimeout(this._deviceAlertsActionsTimeout); + this._getDeviceActions(); + this._getDeviceAlerts(); + } + } + + private async _getDiagnosticButtons(): Promise { + const deviceId = this.deviceId; if (!isComponentLoaded(this.hass, "diagnostics")) { return; } @@ -951,7 +938,8 @@ export class HaConfigDevicePage extends LitElement { links = links.filter(Boolean); - if (this._diagnosticDownloadLinks !== requestId) { + if (this.deviceId !== deviceId) { + // abort if the device has changed return; } if (links.length > 0) { @@ -1176,12 +1164,12 @@ export class HaConfigDevicePage extends LitElement { deviceAlerts.push(...alerts); } + this._deviceAlerts = deviceAlerts; if (deviceAlerts.length) { - this._deviceAlerts = deviceAlerts; - this._deviceAlertsTimeout = window.setTimeout( - () => this._getDeviceAlerts(), - DEVICE_ALERTS_INTERVAL - ); + this._deviceAlertsActionsTimeout = window.setTimeout(() => { + this._getDeviceAlerts(); + this._getDeviceActions(); + }, DEVICE_ALERTS_INTERVAL); } } diff --git a/src/panels/lovelace/cards/hui-card.ts b/src/panels/lovelace/cards/hui-card.ts index cba0e15aea..271e2cd027 100644 --- a/src/panels/lovelace/cards/hui-card.ts +++ b/src/panels/lovelace/cards/hui-card.ts @@ -96,7 +96,9 @@ export class HuiCard extends ReactiveElement { if (!this._element) return {}; if (this._element.getGridOptions) { - return this._element.getGridOptions(); + const options = this._element.getGridOptions(); + // Some custom cards might return undefined, so we ensure we return an object + return options || {}; } if (this._element.getLayoutOptions) { // Disabled for now to avoid spamming the console, need to be re-enabled when hui-card performance are fixed