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

Commit

Permalink
async -> flow
Browse files Browse the repository at this point in the history
Partly cherry-picked from 4303de2

Signed-off-by: Sergey <[email protected]>
  • Loading branch information
nick-skriabin authored and Gondragos committed Jan 30, 2024
1 parent d25814e commit 17f88a1
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/stores/Annotation/Annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,13 +681,13 @@ export const Annotation = types
onSnapshot(self.areas, self.autosave);
}),

async saveDraft(params) {
saveDraft: flow(function* (params) {
// There is no draft to save as it was already saved as an annotation
if (self.submissionStarted) return;
// if this is now a history item or prediction don't save it
if (!self.editable) return;

const result = self.serializeAnnotation({ fast: true });
const result = yield self.serializeAnnotation({ fast: true });
// if this is new annotation and no regions added yet

if (!isFF(FF_LSDV_3009) && !self.pk && !result.length) return;
Expand All @@ -700,7 +700,7 @@ export const Annotation = types

return res;
});
},
}),

submissionInProgress() {
self.submissionStarted = Date.now();
Expand All @@ -710,14 +710,14 @@ export const Annotation = types
if (self.autosave) self.autosave.flush();
},

async saveDraftImmediatelyWithResults(params) {
saveDraftImmediatelyWithResults: flow(function *(params) {
// There is no draft to save as it was already saved as an annotation
if (self.submissionStarted || self.isDraftSaving) return {};
self.setDraftSaving(true);
const res = await self.saveDraft(params);
const res = yield self.saveDraft(params);

return res;
},
}),

pauseAutosave() {
if (!self.autosave) return;
Expand Down Expand Up @@ -935,8 +935,6 @@ export const Annotation = types
},

serializeAnnotation(options) {
// return self.serialized;

document.body.style.cursor = 'wait';

const result = self.results
Expand Down Expand Up @@ -1033,7 +1031,7 @@ export const Annotation = types
if (tagNames.has(obj.from_name) && tagNames.has(obj.to_name)) {
res.push(obj);
}

// Insert image dimensions from result
(() => {
if (!isDefined(obj.original_width)) return;
Expand All @@ -1043,7 +1041,7 @@ export const Annotation = types

if (tag.type !== 'image') return;

const imageEntity = tag.findImageEntity(obj.item_index ?? 0);
const imageEntity = tag.findImageEntity(obj.item_index ?? 0);

if (!imageEntity) return;

Expand Down Expand Up @@ -1346,7 +1344,7 @@ export const Annotation = types
area.setValue(state);
});
self.suggestions.delete(id);

},

rejectSuggestion(id) {
Expand Down

0 comments on commit 17f88a1

Please sign in to comment.