// SPDX-License-Identifier: AGPL-3.0
import { UploadFile, fileUploaderActions, FileUploaderAction } from "./file-uploader-actions";
-import * as _ from 'lodash';
+import { uniqBy } from 'lodash';
export type UploaderState = UploadFile[];
currentTime: 0
}));
const updatedState = state.concat(updateFiles);
- const uniqUpdatedState = _.uniqBy(updatedState, 'file.name');
+ const uniqUpdatedState = uniqBy(updatedState, 'file.name');
return uniqUpdatedState;
},
return updatedState;
},
+ CANCEL_FILES_UPLOAD: () => {
+ state.forEach((file) => {
+ let interval = setInterval(() => {
+ const key = Object.keys((window as any).cancelTokens).find(key => key.indexOf(file.file.name) > -1);
+
+ if (key) {
+ clearInterval(interval);
+ (window as any).cancelTokens[key]();
+ delete (window as any).cancelTokens[key];
+ }
+ }, 100);
+ });
+
+ return [];
+ },
START_UPLOAD: () => {
const startTime = Date.now();
return state.map(f => ({ ...f, startTime, prevTime: startTime }));