@imposium-hub/components 1.27.0 → 1.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imposium-hub/components",
3
- "version": "1.27.0",
3
+ "version": "1.27.1",
4
4
  "description": "React & Typescript component / asset library for Imposium front-ends",
5
5
  "main": "dist/components.js",
6
6
  "scripts": {
@@ -60,18 +60,16 @@ export const deleteAssets = (api : IImposiumAPI, ids : string[], storyId : strin
60
60
  return (dispatch) => {
61
61
  if (window.confirm(`Are you sure you want to delete ${ids.length} assets?`)) {
62
62
  return new Promise<void>((resolve, reject) => {
63
- const requests : Array<Promise<any | Error>> = ids.map((id : string) => (api.deleteAsset(id)));
64
-
65
63
  dispatch(toggleLoading(true));
66
- Promise.all(requests)
67
- .then(() => {
68
- dispatch(getAssets(api, storyId));
69
- resolve();
70
- })
71
- .catch((errors : Error[]) => {
72
- dispatch(toggleLoading(false));
73
- reject();
74
- });
64
+ api.deleteAssets(ids)
65
+ .then(() => {
66
+ dispatch(getAssets(api, storyId));
67
+ resolve();
68
+ })
69
+ .catch((errors : Error[]) => {
70
+ dispatch(toggleLoading(false));
71
+ reject();
72
+ });
75
73
  });
76
74
  }
77
75
  };
package/services/API.ts CHANGED
@@ -8,6 +8,7 @@ export interface IImposiumAPI {
8
8
  getAssetItem(assetId : string);
9
9
  uploadAsset(storyId : string, tags : string, file : File);
10
10
  deleteAsset(assetId : string);
11
+ deleteAssets(assetIds : string[]);
11
12
  copyAsset(assetId : string, data);
12
13
  addAssetTag(assetId : string, tag : string);
13
14
  deleteAssetTag(assetId : string, tag : string);
@@ -348,6 +349,16 @@ export default class API {
348
349
  });
349
350
  }
350
351
 
352
+ public deleteAssets = (assetIds : string[]) : Promise<any | Error> => {
353
+ return this.doRequest({
354
+ method: 'DELETE',
355
+ url: `/assets`,
356
+ data: {
357
+ ids: assetIds
358
+ }
359
+ });
360
+ }
361
+
351
362
  public copyAsset = (assetId : string, data : any) : Promise<any | Error> => {
352
363
 
353
364
  return this.doRequest({