Skip to content

fix: LEAP-649: Saving draft on task switching #7212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions web/libs/datamanager/src/sdk/lsf-sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,8 @@ export class LSFWrapper {
};

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

if (annotationDoesntExist) {
response = await this.datamanager.apiCall("createDraftForTask", { taskID: this.task.id }, data);
response = await this.datamanager.apiCall("createDraftForTask", { taskID: taskId }, data);
} else {
response = await this.datamanager.apiCall(
"createDraftForAnnotation",
{ taskID: this.task.id, annotationID: annotation.pk },
{ taskID: taskId, annotationID: annotation.pk },
data,
);
}
Expand Down
Loading