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

fix: OPTIC-124: Save and update have success/fail toast messages #250

Merged
merged 6 commits into from
Nov 10, 2023
16 changes: 13 additions & 3 deletions src/sdk/lsf-sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,12 @@ export class LSFWrapper {
{ body },
// don't react on duplicated annotations error
{ errorHandler: result => result.status === 409 },
);
).then(result => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

promise chain is broken here because it doesn't pass result through. I'd remove current returns and added final return result the same way as in "update" version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, thanks!

const status = result.$meta?.status;

if (status === 200 || status === 201) return this.datamanager.invoke("toast", { message: "Annotation saved successfully", type: "info" });
else if (status !== undefined) return this.datamanager.invoke("toast", { message: "There was an error saving your Annotation", type: "error" });
});
}, false, loadNext, exitStream);
};

Expand All @@ -587,7 +592,12 @@ export class LSFWrapper {
{
body: serializedAnnotation,
},
);
).then(result => {
const status = result?.$meta?.status;

if (status === 200 || status === 201) return this.datamanager.invoke("toast", { message: "Annotation updated successfully", type: "info" });
else if (status !== undefined) return this.datamanager.invoke("toast", { message: "There was an error updating your Annotation", type: "error" });
});
Travis1282 marked this conversation as resolved.
Show resolved Hide resolved
});

this.datamanager.invoke("updateAnnotation", ls, annotation, result);
Expand Down Expand Up @@ -649,7 +659,7 @@ export class LSFWrapper {
saveDraft = async (target = null) => {
const selected = target || this.lsf?.annotationStore?.selected;
const hasChanges = !!selected?.history.undoIdx && !selected?.submissionStarted;

Travis1282 marked this conversation as resolved.
Show resolved Hide resolved
bmartel marked this conversation as resolved.
Show resolved Hide resolved
if (!hasChanges || !selected) return;
const res = await selected?.saveDraftImmediatelyWithResults();
const status = res?.$meta?.status;
Expand Down