Fix saving Lovelace config (#9041)

This commit is contained in:
Bram Kragten 2021-04-29 18:05:58 +02:00 committed by GitHub
parent 65a30bf60c
commit 542f169b36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 5 deletions

View File

@ -363,11 +363,22 @@ class LovelacePanel extends LitElement {
mode: previousMode,
} = this.lovelace!;
newConfig = this._checkLovelaceConfig(newConfig);
let conf: LovelaceConfig;
// If strategy defined, apply it here.
if (newConfig.strategy) {
conf = await generateLovelaceDashboardStrategy({
config: newConfig,
hass: this.hass!,
narrow: this.narrow,
});
} else {
conf = newConfig;
}
try {
// Optimistic update
this._updateLovelace({
config: newConfig,
rawConfig: undefined,
config: conf,
rawConfig: newConfig,
mode: "storage",
});
this._ignoreNextUpdateEvent = true;

View File

@ -115,8 +115,8 @@ class LovelaceFullConfigEditor extends LitElement {
!this._saving &&
oldLovelace &&
this.lovelace &&
oldLovelace.config !== this.lovelace.config &&
!deepEqual(oldLovelace.config, this.lovelace.config)
oldLovelace.rawConfig !== this.lovelace.rawConfig &&
!deepEqual(oldLovelace.rawConfig, this.lovelace.rawConfig)
) {
showToast(this, {
message: this.hass!.localize(
@ -124,7 +124,7 @@ class LovelaceFullConfigEditor extends LitElement {
),
action: {
action: () => {
this.yamlEditor.value = safeDump(this.lovelace!.config);
this.yamlEditor.value = safeDump(this.lovelace!.rawConfig);
},
text: this.hass!.localize(
"ui.panel.lovelace.editor.raw_editor.reload"