Skip to content

Commit a01b255

Browse files
fix: LEAP-649: Saving draft on task switching (#7212)
Co-authored-by: robot-ci-heartex <[email protected]>
1 parent 2789874 commit a01b255

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

web/libs/datamanager/src/sdk/lsf-sdk.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,8 @@ export class LSFWrapper {
740740
};
741741

742742
onSubmitDraft = async (studio, annotation, params = {}) => {
743+
// It should be preserved as soon as possible because each `await` will allow it to be changed
744+
const taskId = this.task.id;
743745
const annotationDoesntExist = !annotation.pk;
744746
const data = { body: this.prepareData(annotation, { isNewDraft: true }) }; // serializedAnnotation
745747
const hasChanges = this.needsDraftSave(annotation);
@@ -762,11 +764,11 @@ export class LSFWrapper {
762764
let response;
763765

764766
if (annotationDoesntExist) {
765-
response = await this.datamanager.apiCall("createDraftForTask", { taskID: this.task.id }, data);
767+
response = await this.datamanager.apiCall("createDraftForTask", { taskID: taskId }, data);
766768
} else {
767769
response = await this.datamanager.apiCall(
768770
"createDraftForAnnotation",
769-
{ taskID: this.task.id, annotationID: annotation.pk },
771+
{ taskID: taskId, annotationID: annotation.pk },
770772
data,
771773
);
772774
}

0 commit comments

Comments
 (0)