Skip to content

Commit

Permalink
Fix race in lovelace (#19609)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored Feb 1, 2024
1 parent 69f2566 commit 28a0d21
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/panels/lovelace/ha-panel-lovelace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export class LovelacePanel extends LitElement {

private _unsubUpdates?: Promise<UnsubscribeFunc>;

private _loading = false;

public connectedCallback(): void {
super.connectedCallback();
if (
Expand Down Expand Up @@ -162,7 +164,7 @@ export class LovelacePanel extends LitElement {

protected willUpdate(changedProps: PropertyValues) {
super.willUpdate(changedProps);
if (!this.lovelace && this._panelState !== "error") {
if (!this.lovelace && this._panelState !== "error" && !this._loading) {
this._fetchConfig(false);
}
}
Expand Down Expand Up @@ -233,6 +235,8 @@ export class LovelacePanel extends LitElement {
}

private async _fetchConfig(forceDiskRefresh: boolean) {
this._loading = true;

let conf: LovelaceConfig;
let rawConf: LovelaceRawConfig | undefined;
let confMode: Lovelace["mode"] = this.panel!.config.mode;
Expand Down Expand Up @@ -301,6 +305,7 @@ export class LovelacePanel extends LitElement {
rawConf = DEFAULT_CONFIG;
confMode = "generated";
} finally {
this._loading = false;
// Ignore updates for another 2 seconds.
if (this.lovelace && this.lovelace.mode === "yaml") {
setTimeout(() => {
Expand Down

0 comments on commit 28a0d21

Please sign in to comment.