mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-05-01 15:46:40 +07:00
fetching files
This commit is contained in:
parent
1aff4d5b73
commit
ec91c5533b
5 changed files with 34 additions and 8 deletions
src/redux/uploads
|
@ -2,7 +2,7 @@ import assocPath from 'ramda/es/assocPath';
|
|||
import omit from 'ramda/es/omit';
|
||||
|
||||
import { UPLOAD_ACTIONS, EMPTY_UPLOAD_STATUS } from './constants';
|
||||
import { uploadAddStatus, uploadDropStatus, uploadSetStatus } from './actions';
|
||||
import { uploadAddStatus, uploadDropStatus, uploadSetStatus, uploadAddFile } from './actions';
|
||||
import { IUploadState } from './reducer';
|
||||
|
||||
const addStatus = (
|
||||
|
@ -31,8 +31,19 @@ const setStatus = (
|
|||
{ ...state.statuses, [temp_id]: { ...(state.statuses[temp_id] || EMPTY_UPLOAD_STATUS), ...status } },
|
||||
state
|
||||
);
|
||||
|
||||
const addFile = (
|
||||
state: IUploadState,
|
||||
{ file }: ReturnType<typeof uploadAddFile>
|
||||
): IUploadState => assocPath(
|
||||
['files'],
|
||||
{ ...state.files, [file.id]: file },
|
||||
state
|
||||
);
|
||||
|
||||
export const UPLOAD_HANDLERS = {
|
||||
[UPLOAD_ACTIONS.ADD_STATUS]: addStatus,
|
||||
[UPLOAD_ACTIONS.DROP_STATUS]: dropStatus,
|
||||
[UPLOAD_ACTIONS.SET_STATUS]: setStatus,
|
||||
[UPLOAD_ACTIONS.ADD_FILE]: addFile,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue