Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
revert needs draft logic for save draft
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Clark authored and Travis Clark committed Dec 8, 2023
1 parent 4c458a2 commit 2e35577
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/sdk/lsf-sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,21 +686,22 @@ export class LSFWrapper {
(annotation.draftSaved ? new Date(annotation.history.lastAdditionTime) > new Date(annotation.draftSaved) : true);

saveDraft = async (target = null) => {
const annotation = target || this.lsf?.annotationStore?.selected;
const hasChanges = this.needsDraftSave(annotation);
const submissionInProgress = annotation?.submissionStarted;
const selected = target || this.lsf?.annotationStore?.selected;
const hasChanges = selected.history.hasChanges;
const submissionInProgress = selected?.submissionStarted;
const draftIsFresh = new Date(selected.draftSaved) > new Date() - selected.autosaveDelay;

if (annotation?.isDraftSaving) {
await when(() => !annotation.isDraftSaving);
if (selected?.isDraftSaving || draftIsFresh) {
await when(() => !selected.isDraftSaving);
this.draftToast(200);
}
else if (hasChanges && annotation && !submissionInProgress) {
const res = await annotation?.saveDraftImmediatelyWithResults();
else if (hasChanges && selected && !submissionInProgress) {
const res = await selected?.saveDraftImmediatelyWithResults();
const status = res?.$meta?.status;

this.draftToast(status);
}
};
};

onSubmitDraft = async (studio, annotation, params = {}) => {
const annotationDoesntExist = !annotation.pk;
Expand Down

0 comments on commit 2e35577

Please sign in to comment.