Update model immediately to avoid race conditions between UI actions and delayed model updates
This commit is contained in:
parent
49de352011
commit
edb4782971
|
|
@ -32,8 +32,6 @@ export class WorkflowDefinitionEditor {
|
|||
private canvas: HTMLElsaCanvasElement;
|
||||
private container: HTMLDivElement;
|
||||
private toolbox: HTMLElsaWorkflowDefinitionEditorToolboxElement;
|
||||
private readonly emitActivityChangedDebounced: (e: ActivityPropertyChangedEventArgs) => void;
|
||||
private readonly updateModelDebounced: () => void;
|
||||
private readonly saveChangesDebounced: () => void;
|
||||
private readonly workflowDefinitionApi: WorkflowDefinitionsApi;
|
||||
|
||||
|
|
@ -42,8 +40,6 @@ export class WorkflowDefinitionEditor {
|
|||
this.pluginRegistry = Container.get(PluginRegistry);
|
||||
this.activityNameFormatter = Container.get(ActivityNameFormatter);
|
||||
this.portProviderRegistry = Container.get(PortProviderRegistry);
|
||||
this.emitActivityChangedDebounced = debounce(this.emitActivityChanged, 100);
|
||||
this.updateModelDebounced = debounce(this.updateModel, 10);
|
||||
this.saveChangesDebounced = debounce(this.saveChanges, 1000);
|
||||
this.workflowDefinitionApi = Container.get(WorkflowDefinitionsApi);
|
||||
}
|
||||
|
|
@ -89,7 +85,7 @@ export class WorkflowDefinitionEditor {
|
|||
|
||||
@Listen('graphUpdated')
|
||||
private async handleGraphUpdated(e: CustomEvent<GraphUpdatedArgs>) {
|
||||
this.updateModelDebounced();
|
||||
await this.updateModel();
|
||||
this.saveChangesDebounced();
|
||||
}
|
||||
|
||||
|
|
@ -241,12 +237,12 @@ export class WorkflowDefinitionEditor {
|
|||
});
|
||||
|
||||
await this.updateModel();
|
||||
this.emitActivityChangedDebounced({...e.detail, workflowEditor: this.el});
|
||||
await this.emitActivityChanged(e.detail.activity, e.detail.propertyName);
|
||||
this.saveChangesDebounced();
|
||||
}
|
||||
|
||||
private onWorkflowPropsUpdated = (e: CustomEvent<WorkflowDefinitionPropsUpdatedArgs>) => {
|
||||
this.updateModelDebounced();
|
||||
private onWorkflowPropsUpdated = async (e: CustomEvent<WorkflowDefinitionPropsUpdatedArgs>) => {
|
||||
await this.updateModel();
|
||||
this.saveChangesDebounced();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue