2017-07-11 15:37:43 +00:00
|
|
|
import * as ActionTypes from '../../../constants';
|
|
|
|
|
2019-07-24 16:55:58 +00:00
|
|
|
// 1,000,000 bytes in a MB. can't upload if totalSize is bigger than this.
|
|
|
|
const initialState = {
|
2020-03-03 21:33:52 +00:00
|
|
|
list: [],
|
|
|
|
totalSize: 0
|
2019-07-24 16:55:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const assets = (state = initialState, action) => {
|
2017-07-11 15:37:43 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case ActionTypes.SET_ASSETS:
|
2020-03-03 21:33:52 +00:00
|
|
|
return { list: action.assets, totalSize: action.totalSize };
|
2019-09-10 22:42:23 +00:00
|
|
|
case ActionTypes.DELETE_ASSET:
|
|
|
|
return { list: state.list.filter(asset => asset.key !== action.key) };
|
2017-07-11 15:37:43 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default assets;
|