1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { CollectionUploaderAction, collectionUploaderActions, UploadFile } from "./collection-uploader-actions";
7 export type CollectionUploaderState = UploadFile[];
9 const initialState: CollectionUploaderState = [];
11 export const collectionUploaderReducer = (state: CollectionUploaderState = initialState, action: CollectionUploaderAction) => {
12 return collectionUploaderActions.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: () => [],