mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Ignore LL updates for a second in YAML mode (#3433)
This commit is contained in:
parent
dcfed5d7e1
commit
689e37782e
@ -49,7 +49,8 @@ class LovelacePanel extends LitElement {
|
|||||||
|
|
||||||
private mqls?: MediaQueryList[];
|
private mqls?: MediaQueryList[];
|
||||||
|
|
||||||
private _saving: boolean = false;
|
private _ignoreNextUpdateEventBecauseOfSave = false;
|
||||||
|
private _ignoreUpdateUntilTime: number | undefined;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@ -184,19 +185,25 @@ class LovelacePanel extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _lovelaceChanged() {
|
private _lovelaceChanged() {
|
||||||
if (this._saving) {
|
if (
|
||||||
this._saving = false;
|
this._ignoreUpdateUntilTime &&
|
||||||
} else {
|
new Date().getTime() < this._ignoreUpdateUntilTime
|
||||||
showToast(this, {
|
) {
|
||||||
message: this.hass!.localize("ui.panel.lovelace.changed_toast.message"),
|
return;
|
||||||
action: {
|
|
||||||
action: () => this._fetchConfig(false),
|
|
||||||
text: this.hass!.localize("ui.panel.lovelace.changed_toast.refresh"),
|
|
||||||
},
|
|
||||||
duration: 0,
|
|
||||||
dismissable: false,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
if (this._ignoreNextUpdateEventBecauseOfSave) {
|
||||||
|
this._ignoreNextUpdateEventBecauseOfSave = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
showToast(this, {
|
||||||
|
message: this.hass!.localize("ui.panel.lovelace.changed_toast.message"),
|
||||||
|
action: {
|
||||||
|
action: () => this._fetchConfig(false),
|
||||||
|
text: this.hass!.localize("ui.panel.lovelace.changed_toast.refresh"),
|
||||||
|
},
|
||||||
|
duration: 0,
|
||||||
|
dismissable: false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _forceFetchConfig() {
|
private _forceFetchConfig() {
|
||||||
@ -214,6 +221,13 @@ class LovelacePanel extends LitElement {
|
|||||||
confProm = llWindow.llConfProm;
|
confProm = llWindow.llConfProm;
|
||||||
llWindow.llConfProm = undefined;
|
llWindow.llConfProm = undefined;
|
||||||
} else {
|
} else {
|
||||||
|
// Refreshing a YAML config can trigger an update event. We will ignore
|
||||||
|
// all update events for a second after we refresh, as we already have
|
||||||
|
// the latest config in that case.
|
||||||
|
if (this.lovelace && this.lovelace.mode === "yaml") {
|
||||||
|
this._ignoreUpdateUntilTime = new Date().getTime() + 1000;
|
||||||
|
}
|
||||||
|
|
||||||
confProm = fetchConfig(this.hass!.connection, forceDiskRefresh);
|
confProm = fetchConfig(this.hass!.connection, forceDiskRefresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +279,7 @@ class LovelacePanel extends LitElement {
|
|||||||
config: newConfig,
|
config: newConfig,
|
||||||
mode: "storage",
|
mode: "storage",
|
||||||
});
|
});
|
||||||
this._saving = true;
|
this._ignoreNextUpdateEventBecauseOfSave = true;
|
||||||
await saveConfig(this.hass!, newConfig);
|
await saveConfig(this.hass!, newConfig);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// tslint:disable-next-line
|
// tslint:disable-next-line
|
||||||
|
Loading…
x
Reference in New Issue
Block a user