mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 01:36:49 +00:00
Dont fetch device actions on first updated (#26028)
This commit is contained in:
parent
eecd765d09
commit
1db8ef37a2
@ -10,7 +10,7 @@ import {
|
|||||||
mdiPlusCircle,
|
mdiPlusCircle,
|
||||||
mdiRestore,
|
mdiRestore,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import type { CSSResultGroup, TemplateResult } from "lit";
|
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
|
||||||
import { LitElement, css, html, nothing } from "lit";
|
import { LitElement, css, html, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { ifDefined } from "lit/directives/if-defined";
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
@ -273,22 +273,24 @@ export class HaConfigDevicePage extends LitElement {
|
|||||||
findBatteryChargingEntity(this.hass, entities)
|
findBatteryChargingEntity(this.hass, entities)
|
||||||
);
|
);
|
||||||
|
|
||||||
public willUpdate(changedProps) {
|
public willUpdate(changedProps: PropertyValues<this>) {
|
||||||
super.willUpdate(changedProps);
|
super.willUpdate(changedProps);
|
||||||
|
|
||||||
if (changedProps.has("deviceId") || changedProps.has("entries")) {
|
if (changedProps.has("deviceId")) {
|
||||||
this._deviceActions = [];
|
this._deviceActions = [];
|
||||||
this._deviceAlerts = [];
|
this._deviceAlerts = [];
|
||||||
this._deleteButtons = [];
|
this._deleteButtons = [];
|
||||||
this._diagnosticDownloadLinks = [];
|
this._diagnosticDownloadLinks = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changedProps.has("deviceId") || changedProps.has("entries")) {
|
||||||
this._fetchData();
|
this._fetchData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected firstUpdated(changedProps) {
|
protected firstUpdated(changedProps: PropertyValues) {
|
||||||
super.firstUpdated(changedProps);
|
super.firstUpdated(changedProps);
|
||||||
loadDeviceRegistryDetailDialog();
|
loadDeviceRegistryDetailDialog();
|
||||||
this._fetchData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected updated(changedProps) {
|
protected updated(changedProps) {
|
||||||
@ -989,6 +991,7 @@ export class HaConfigDevicePage extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _getDeleteActions() {
|
private _getDeleteActions() {
|
||||||
|
const deviceId = this.deviceId;
|
||||||
const device = this.hass.devices[this.deviceId];
|
const device = this.hass.devices[this.deviceId];
|
||||||
|
|
||||||
if (!device) {
|
if (!device) {
|
||||||
@ -1058,12 +1061,18 @@ export class HaConfigDevicePage extends LitElement {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (this.deviceId !== deviceId) {
|
||||||
|
// abort if the device has changed
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (buttons.length > 0) {
|
if (buttons.length > 0) {
|
||||||
this._deleteButtons = buttons;
|
this._deleteButtons = buttons;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _getDeviceActions() {
|
private async _getDeviceActions() {
|
||||||
|
const deviceId = this.deviceId;
|
||||||
const device = this.hass.devices[this.deviceId];
|
const device = this.hass.devices[this.deviceId];
|
||||||
|
|
||||||
if (!device) {
|
if (!device) {
|
||||||
@ -1157,14 +1166,25 @@ export class HaConfigDevicePage extends LitElement {
|
|||||||
|
|
||||||
// load matter device actions async to avoid an UI with 0 actions when the matter integration needs very long to get node diagnostics
|
// load matter device actions async to avoid an UI with 0 actions when the matter integration needs very long to get node diagnostics
|
||||||
matter.getMatterDeviceActions(this, this.hass, device).then((actions) => {
|
matter.getMatterDeviceActions(this, this.hass, device).then((actions) => {
|
||||||
|
if (this.deviceId !== deviceId) {
|
||||||
|
// abort if the device has changed
|
||||||
|
return;
|
||||||
|
}
|
||||||
this._deviceActions = [...actions, ...(this._deviceActions || [])];
|
this._deviceActions = [...actions, ...(this._deviceActions || [])];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.deviceId !== deviceId) {
|
||||||
|
// abort if the device has changed
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._deviceActions = deviceActions;
|
this._deviceActions = deviceActions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _getDeviceAlerts() {
|
private async _getDeviceAlerts() {
|
||||||
|
const deviceId = this.deviceId;
|
||||||
|
|
||||||
const device = this.hass.devices[this.deviceId];
|
const device = this.hass.devices[this.deviceId];
|
||||||
|
|
||||||
if (!device) {
|
if (!device) {
|
||||||
@ -1188,6 +1208,11 @@ export class HaConfigDevicePage extends LitElement {
|
|||||||
deviceAlerts.push(...alerts);
|
deviceAlerts.push(...alerts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.deviceId !== deviceId) {
|
||||||
|
// abort if the device has changed
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._deviceAlerts = deviceAlerts;
|
this._deviceAlerts = deviceAlerts;
|
||||||
if (deviceAlerts.length) {
|
if (deviceAlerts.length) {
|
||||||
this._deviceAlertsActionsTimeout = window.setTimeout(() => {
|
this._deviceAlertsActionsTimeout = window.setTimeout(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user