Skip to content
This repository was archived by the owner on Dec 7, 2021. It is now read-only.

Commit f11edfa

Browse files
tbarlow12wbreza
authored andcommitted
Register mixins and run async loop
1 parent 0fa8dba commit f11edfa

3 files changed

Lines changed: 10 additions & 26 deletions

File tree

src/react/components/pages/editorPage/editorPage.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export default class EditorPage extends React.Component<IEditorPageProps, IEdito
316316
const newProject: IProject = {
317317
...project,
318318
tags: project.tags.map((t) => (t.name === tagName) ? {...t, name: newTagName} : t),
319-
}
319+
};
320320
this.setState({
321321
project: newProject,
322322
selectedAsset: asset || selectedAsset,
@@ -337,10 +337,9 @@ export default class EditorPage extends React.Component<IEditorPageProps, IEdito
337337
const { project } = this.props;
338338
const newProject: IProject = {
339339
...project,
340-
tags: project.tags.filter((t) => t.name !== tagName)
341-
}
340+
tags: project.tags.filter((t) => t.name !== tagName),
341+
};
342342
await this.props.actions.saveProject(newProject);
343-
debugger;
344343

345344
const assetService = new AssetService(project);
346345
const asset = await assetService.deleteTag(project.assets, tagName, selectedAsset);

src/services/assetService.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { TFRecordsBuilder, FeatureType } from "../providers/export/tensorFlowRec
88
import HtmlFileReader from "../common/htmlFileReader";
99
import { encodeFileURI } from "../common/utils";
1010
import _ from "lodash";
11+
import registerMixins from "../registerMixins";
1112

1213
describe("Asset Service", () => {
1314
describe("Static Methods", () => {
@@ -340,6 +341,10 @@ describe("Asset Service", () => {
340341
return project;
341342
}
342343

344+
beforeAll(() => {
345+
registerMixins();
346+
})
347+
343348
it("Deletes tag from assets", async () => {
344349
const tag1 = "tag1";
345350
const tag2 = "tag2";

src/services/assetService.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,9 @@ export class AssetService {
247247
return;
248248
}
249249
const assetKeys = Object.keys(assets);
250+
250251
// Loop over assets and update if necessary
251-
for (const assetKey of assetKeys) {
252+
await assetKeys.forEachAsync(async (assetKey) => {
252253
const asset = assets[assetKey];
253254
if (asset.state !== AssetState.Tagged) {
254255
return;
@@ -258,28 +259,7 @@ export class AssetService {
258259
if (updatedAssetMetadata) {
259260
await this.save(updatedAssetMetadata);
260261
}
261-
}
262-
if (currentAsset) {
263-
return this.updateTagInAssetMetadata(currentAsset, tagName, transformer);
264-
}
265-
/*
266-
TODO: Replace with async
267-
268-
For some reason in tests, the `forEachAsync` is not recognized as a function
269-
270-
await assetKeys.forEachAsync(async (assetKey) => {
271-
const asset = project.assets[assetKey];
272-
if (asset.state !== AssetState.Tagged) {
273-
return;
274-
}
275-
const assetMetadata = await assetService.getAssetMetadata(asset);
276-
const updatedAssetMetadata = this.updateTagInAssetMetadata(assetMetadata, tagName, transformer);
277-
if (updatedAssetMetadata) {
278-
await assetService.save(updatedAssetMetadata);
279-
}
280262
});
281-
282-
*/
283263
}
284264

285265
/**

0 commit comments

Comments
 (0)