1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { UploadFile, fileUploaderActions, FileUploaderAction } from "./file-uploader-actions";
7 export type UploaderState = UploadFile[];
9 const initialState: UploaderState = [];
11 export const fileUploaderReducer = (state: UploaderState = initialState, action: FileUploaderAction) => {
12 return fileUploaderActions.match(action, {
13 SET_UPLOAD_FILES: files => files.map((f, idx) => ({
24 const startTime = Date.now();
25 return state.map(f => ({...f, startTime, prevTime: startTime}));
27 SET_UPLOAD_PROGRESS: ({ fileId, loaded, total, currentTime }) =>
28 state.map(f => f.id === fileId ? {
33 prevTime: f.currentTime,
36 CLEAR_UPLOAD: () => [],