+ UPDATE_UPLOAD_FILES: files => {
+ const updateFiles = files.map((f, idx) => ({
+ id: state.length + idx,
+ file: f,
+ prevLoaded: 0,
+ loaded: 0,
+ total: 0,
+ startTime: 0,
+ prevTime: 0,
+ currentTime: 0
+ }));
+ const updatedState = state.concat(updateFiles);
+ const uniqUpdatedState = uniqBy(updatedState, 'file.name');
+
+ return uniqUpdatedState;
+ },
+ DELETE_UPLOAD_FILE: file => {
+ const idToDelete: number = file.id;
+ const updatedState = state.filter(file => file.id !== idToDelete);
+
+ 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 [];
+ },