Skip to content

Commit 6fbf29f

Browse files
committed
prevent bundle unlocking before completion
1 parent f0ceb47 commit 6fbf29f

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

src/components/HOCs/WithTaskBundle/WithTaskBundle.jsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export function WithTaskBundle(WrappedComponent) {
3333
loading: false,
3434
updateTaskBundleError: false,
3535
isDeletingBundle: false,
36+
isSubmittingTasks: false,
3637
};
3738

3839
refreshLockInterval = null;
@@ -71,15 +72,15 @@ export function WithTaskBundle(WrappedComponent) {
7172

7273
componentWillUnmount() {
7374
this.stopLockRefresh();
74-
if (!this.state.isDeletingBundle) {
75+
if (!this.state.isDeletingBundle && !this.state.isSubmittingTasks) {
7576
this.unlockBundleTasks();
7677
}
7778
window.removeEventListener("beforeunload", this.handleBeforeUnload);
7879
}
7980

8081
handleBeforeUnload = () => {
8182
this.stopLockRefresh();
82-
if (!this.state.isDeletingBundle) {
83+
if (!this.state.isDeletingBundle && !this.state.isSubmittingTasks) {
8384
this.unlockBundleTasks();
8485
}
8586
};
@@ -474,6 +475,14 @@ export function WithTaskBundle(WrappedComponent) {
474475
}
475476
};
476477

478+
setSubmittingTasks = (isSubmitting) => {
479+
this.setState({ isSubmittingTasks: isSubmitting });
480+
};
481+
482+
clearSubmissionState = () => {
483+
this.setState({ isSubmittingTasks: false });
484+
};
485+
477486
render() {
478487
return (
479488
<WrappedComponent
@@ -499,6 +508,9 @@ export function WithTaskBundle(WrappedComponent) {
499508
resetSelectedTasks={this.resetSelectedTasks}
500509
error={this.state.error}
501510
bundlingDisabledReason={this.state.bundlingDisabledReason}
511+
setSubmittingTasks={this.setSubmittingTasks}
512+
clearSubmissionState={this.clearSubmissionState}
513+
isSubmittingTasks={this.state.isSubmittingTasks}
502514
/>
503515
);
504516
}

src/components/TaskPane/ActiveTaskDetails/ActiveTaskControls/ActiveTaskControls.jsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ export class ActiveTaskControls extends Component {
132132
/** Mark the task as complete with the given status */
133133
complete = async (taskStatus) => {
134134
this.setState({ completingTask: true });
135+
136+
// Notify WithTaskBundle that task submission is starting
137+
if (this.props.setSubmittingTasks) {
138+
this.props.setSubmittingTasks(true);
139+
}
140+
135141
try {
136142
const taskBundle = await this.props.updateTaskBundle();
137143

@@ -179,9 +185,16 @@ export class ActiveTaskControls extends Component {
179185
}
180186
} catch (error) {
181187
this.setState({ completingTask: false });
188+
// Clear submission state on error
189+
if (this.props.clearSubmissionState) {
190+
this.props.clearSubmissionState();
191+
}
182192
throw error;
183193
} finally {
184194
this.setState({ completingTask: false });
195+
if (this.props.clearSubmissionState) {
196+
this.props.clearSubmissionState();
197+
}
185198
}
186199
};
187200

0 commit comments

Comments
 (0)