Skip to content

Commit

Permalink
fix: LEAP-453: Fix annotation and draft being requested at the same t…
Browse files Browse the repository at this point in the history
  • Loading branch information
juliosgarbi authored Jun 26, 2024
1 parent ff6d2ac commit 88a45a7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions web/libs/editor/src/stores/AppStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,19 @@ export default types
});
}

function waitForDraftSubmission() {
return new Promise((resolve) => {
if (!self.annotationStore.selected.isDraftSaving) resolve();

const checkInterval = setInterval(() => {
if (!self.annotationStore.selected.isDraftSaving) {
clearInterval(checkInterval);
resolve();
}
}, 100);
});
}

// Set `isSubmitting` flag to block [Submit] and related buttons during request
// to prevent from sending duplicating requests.
// Better to return request's Promise from SDK to make this work perfect.
Expand Down Expand Up @@ -562,6 +575,7 @@ export default types
}
handleSubmittingFlag(async () => {
if (isFF(FF_CUSTOM_SCRIPT)) {
await self.waitForDraftSubmission();
const allowedToSave = await getEnv(self).events.invoke("beforeSaveAnnotation", self, entity, { event });
if (allowedToSave && allowedToSave.some((x) => x === false)) return;

Expand Down Expand Up @@ -937,6 +951,7 @@ export default types
unskipTask,
setTaskHistory,
submitDraft,
waitForDraftSubmission,
submitAnnotation,
updateAnnotation,
acceptAnnotation,
Expand Down

0 comments on commit 88a45a7

Please sign in to comment.