1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-05-05 09:36:41 +07:00

tried to make upload sagas

This commit is contained in:
muerwre 2019-08-07 15:09:28 +07:00
parent caf85c104f
commit 3872ff5903
9 changed files with 180 additions and 80 deletions
src/redux/uploads

View file

@ -1,3 +1,38 @@
export const UPLOAD_HANDLERS = {
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 { IUploadState } from './reducer';
const addStatus = (
state: IUploadState,
{ temp_id, status }: ReturnType<typeof uploadAddStatus>
): IUploadState => assocPath(
['statuses'],
{ ...state.statuses, [temp_id]: { ...EMPTY_UPLOAD_STATUS, ...status } },
state
);
const dropStatus = (
state: IUploadState,
{ temp_id }: ReturnType<typeof uploadDropStatus>
): IUploadState => assocPath(
['statuses'],
omit([temp_id], state.statuses),
state,
);
const setStatus = (
state: IUploadState,
{ temp_id, status }: ReturnType<typeof uploadSetStatus>
): IUploadState => assocPath(
['statuses'],
{ ...state.statuses, [temp_id]: { ...(state.statuses[temp_id] || EMPTY_UPLOAD_STATUS), ...status } },
state
);
export const UPLOAD_HANDLERS = {
[UPLOAD_ACTIONS.ADD_STATUS]: addStatus,
[UPLOAD_ACTIONS.DROP_STATUS]: dropStatus,
[UPLOAD_ACTIONS.SET_STATUS]: setStatus,
};