mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +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 _saving: boolean = false;
|
||||
private _ignoreNextUpdateEventBecauseOfSave = false;
|
||||
private _ignoreUpdateUntilTime: number | undefined;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@ -184,9 +185,16 @@ class LovelacePanel extends LitElement {
|
||||
}
|
||||
|
||||
private _lovelaceChanged() {
|
||||
if (this._saving) {
|
||||
this._saving = false;
|
||||
} else {
|
||||
if (
|
||||
this._ignoreUpdateUntilTime &&
|
||||
new Date().getTime() < this._ignoreUpdateUntilTime
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (this._ignoreNextUpdateEventBecauseOfSave) {
|
||||
this._ignoreNextUpdateEventBecauseOfSave = false;
|
||||
return;
|
||||
}
|
||||
showToast(this, {
|
||||
message: this.hass!.localize("ui.panel.lovelace.changed_toast.message"),
|
||||
action: {
|
||||
@ -197,7 +205,6 @@ class LovelacePanel extends LitElement {
|
||||
dismissable: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private _forceFetchConfig() {
|
||||
this._fetchConfig(true);
|
||||
@ -214,6 +221,13 @@ class LovelacePanel extends LitElement {
|
||||
confProm = llWindow.llConfProm;
|
||||
llWindow.llConfProm = undefined;
|
||||
} 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);
|
||||
}
|
||||
|
||||
@ -265,7 +279,7 @@ class LovelacePanel extends LitElement {
|
||||
config: newConfig,
|
||||
mode: "storage",
|
||||
});
|
||||
this._saving = true;
|
||||
this._ignoreNextUpdateEventBecauseOfSave = true;
|
||||
await saveConfig(this.hass!, newConfig);
|
||||
} catch (err) {
|
||||
// tslint:disable-next-line
|
||||
|
Loading…
x
Reference in New Issue
Block a user