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

Commit a73b540

Browse files
committed
async over promises
1 parent 9e25fcc commit a73b540

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/sdk/lsf-sdk.js

+12-13
Original file line numberDiff line numberDiff line change
@@ -556,20 +556,19 @@ export class LSFWrapper {
556556
const exitStream = this.shouldExitStream();
557557
const loadNext = exitStream ? false : this.shouldLoadNext();
558558

559-
await this.submitCurrentAnnotation("submitAnnotation", async (taskID, body) => {
559+
const result = await this.submitCurrentAnnotation("submitAnnotation", async (taskID, body) => {
560560
return await this.datamanager.apiCall(
561561
"submitAnnotation",
562562
{ taskID },
563563
{ body },
564564
// don't react on duplicated annotations error
565565
{ errorHandler: result => result.status === 409 },
566-
).then(result => {
567-
const status = result.$meta?.status;
568-
569-
if (status === 200 || status === 201) return this.datamanager.invoke("toast", { message: "Annotation saved successfully", type: "info" });
570-
else if (status !== undefined) return this.datamanager.invoke("toast", { message: "There was an error saving your Annotation", type: "error" });
571-
});
566+
);
572567
}, false, loadNext, exitStream);
568+
const status = result.$meta?.status;
569+
570+
if (status === 200 || status === 201) this.datamanager.invoke("toast", { message: "Annotation saved successfully", type: "info" });
571+
else if (status !== undefined) this.datamanager.invoke("toast", { message: "There was an error saving your Annotation", type: "error" });
573572
};
574573

575574
/** @private */
@@ -592,13 +591,12 @@ export class LSFWrapper {
592591
{
593592
body: serializedAnnotation,
594593
},
595-
).then(result => {
596-
const status = result?.$meta?.status;
597-
598-
if (status === 200 || status === 201) return this.datamanager.invoke("toast", { message: "Annotation updated successfully", type: "info" });
599-
else if (status !== undefined) return this.datamanager.invoke("toast", { message: "There was an error updating your Annotation", type: "error" });
600-
});
594+
);
601595
});
596+
const status = result?.$meta?.status;
597+
598+
if (status === 200 || status === 201) this.datamanager.invoke("toast", { message: "Annotation updated successfully", type: "info" });
599+
else if (status !== undefined) this.datamanager.invoke("toast", { message: "There was an error updating your Annotation", type: "error" });
602600

603601
this.datamanager.invoke("updateAnnotation", ls, annotation, result);
604602

@@ -853,6 +851,7 @@ export class LSFWrapper {
853851
} else {
854852
await this.loadTask();
855853
}
854+
return result;
856855
}
857856

858857
/** @private */

0 commit comments

Comments
 (0)