Skip to content

Commit

Permalink
Merge pull request #223 from tnc-ca-geo/ts-refactor-cleanup
Browse files Browse the repository at this point in the history
Updates required for animl-api TypeScript refactor
  • Loading branch information
nathanielrindlaub authored Aug 8, 2024
2 parents 2e3b1c4 + 47723bc commit 3115d7a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/features/review/labelMiddleware.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ObjectID } from 'bson';
import _ from 'lodash';
import { addLabelEnd } from '../loupe/loupeSlice';
import {
editLabel,
Expand Down Expand Up @@ -49,10 +50,14 @@ export const labelMiddleware = (store) => (next) => (action) => {
if (tempObjs.length) {
store.dispatch(
editLabel('create', 'objects', {
objects: tempObjs.map(({ newObject, imgId }) => ({
object: newObject,
imageId: imgId,
})),
objects: tempObjs.map(({ newObject, imgId }) => {
const obj = _.cloneDeep(newObject);
obj.labels = obj.labels.map((lbl) => ({ ...lbl, imageId: imgId }));
return {
object: obj,
imageId: imgId,
};
}),
}),
);
}
Expand Down Expand Up @@ -144,7 +149,9 @@ export const labelMiddleware = (store) => (next) => (action) => {
const objects = [];
lbls.forEach(({ imgId, objId, validated }) => {
const object = findObject(workingImages, imgId, objId);
const allLabelsInvalidated = object.labels.every((lbl) => lbl.validation && lbl.validation.validated === false);
const allLabelsInvalidated = object.labels.every(
(lbl) => lbl.validation && lbl.validation.validated === false,
);
const locked = (!validated && allLabelsInvalidated) || validated;
objects.push({ imgId, objId, locked });
});
Expand Down

0 comments on commit 3115d7a

Please sign in to comment.