mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix race in lovelace (#19609)
This commit is contained in:
parent
69f2566526
commit
28a0d216f9
@ -73,6 +73,8 @@ export class LovelacePanel extends LitElement {
|
|||||||
|
|
||||||
private _unsubUpdates?: Promise<UnsubscribeFunc>;
|
private _unsubUpdates?: Promise<UnsubscribeFunc>;
|
||||||
|
|
||||||
|
private _loading = false;
|
||||||
|
|
||||||
public connectedCallback(): void {
|
public connectedCallback(): void {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
if (
|
if (
|
||||||
@ -162,7 +164,7 @@ export class LovelacePanel extends LitElement {
|
|||||||
|
|
||||||
protected willUpdate(changedProps: PropertyValues) {
|
protected willUpdate(changedProps: PropertyValues) {
|
||||||
super.willUpdate(changedProps);
|
super.willUpdate(changedProps);
|
||||||
if (!this.lovelace && this._panelState !== "error") {
|
if (!this.lovelace && this._panelState !== "error" && !this._loading) {
|
||||||
this._fetchConfig(false);
|
this._fetchConfig(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,6 +235,8 @@ export class LovelacePanel extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async _fetchConfig(forceDiskRefresh: boolean) {
|
private async _fetchConfig(forceDiskRefresh: boolean) {
|
||||||
|
this._loading = true;
|
||||||
|
|
||||||
let conf: LovelaceConfig;
|
let conf: LovelaceConfig;
|
||||||
let rawConf: LovelaceRawConfig | undefined;
|
let rawConf: LovelaceRawConfig | undefined;
|
||||||
let confMode: Lovelace["mode"] = this.panel!.config.mode;
|
let confMode: Lovelace["mode"] = this.panel!.config.mode;
|
||||||
@ -301,6 +305,7 @@ export class LovelacePanel extends LitElement {
|
|||||||
rawConf = DEFAULT_CONFIG;
|
rawConf = DEFAULT_CONFIG;
|
||||||
confMode = "generated";
|
confMode = "generated";
|
||||||
} finally {
|
} finally {
|
||||||
|
this._loading = false;
|
||||||
// Ignore updates for another 2 seconds.
|
// Ignore updates for another 2 seconds.
|
||||||
if (this.lovelace && this.lovelace.mode === "yaml") {
|
if (this.lovelace && this.lovelace.mode === "yaml") {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user