Fix race condition with Data Entry Flow Progress (#18775)

This commit is contained in:
Bram Kragten 2023-11-27 11:28:49 +01:00 committed by GitHub
parent 8c39ed46a8
commit 22e86af5b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,15 +2,15 @@ import "@material/mwc-button";
import { mdiClose, mdiHelpCircle } from "@mdi/js"; import { mdiClose, mdiHelpCircle } from "@mdi/js";
import type { UnsubscribeFunc } from "home-assistant-js-websocket"; import type { UnsubscribeFunc } from "home-assistant-js-websocket";
import { import {
css,
CSSResultGroup, CSSResultGroup,
html,
LitElement, LitElement,
PropertyValues, PropertyValues,
css,
html,
nothing, nothing,
} from "lit"; } from "lit";
import { customElement, state } from "lit/decorators"; import { customElement, state } from "lit/decorators";
import { fireEvent, HASSDomEvent } from "../../common/dom/fire_event"; import { HASSDomEvent, fireEvent } from "../../common/dom/fire_event";
import "../../components/ha-circular-progress"; import "../../components/ha-circular-progress";
import "../../components/ha-dialog"; import "../../components/ha-dialog";
import "../../components/ha-icon-button"; import "../../components/ha-icon-button";
@ -410,7 +410,7 @@ class DataEntryFlowDialog extends LitElement {
this._step = step; this._step = step;
} }
private _subscribeDataEntryFlowProgressed() { private async _subscribeDataEntryFlowProgressed() {
if (this._unsubDataEntryFlowProgressed) { if (this._unsubDataEntryFlowProgressed) {
return; return;
} }
@ -421,10 +421,17 @@ class DataEntryFlowDialog extends LitElement {
return; return;
} }
this._processStep( this._processStep(
this._params!.flowConfig.fetchFlow(this.hass, this._step?.flow_id) this._params!.flowConfig.fetchFlow(this.hass, this._step.flow_id)
); );
} }
); );
if (this._step?.flow_id) {
await this._unsubDataEntryFlowProgressed;
// fetch flow after we subscribe to the event, so we don't miss the first event
this._processStep(
this._params!.flowConfig.fetchFlow(this.hass, this._step.flow_id)
);
}
} }
static get styles(): CSSResultGroup { static get styles(): CSSResultGroup {