spee.ch/react/reducers/index.js

43 lines
1,015 B
JavaScript
Raw Normal View History

import {FILE_CLEAR, FILE_SELECTED, METADATA_UPDATE} from '../actions';
2018-01-09 02:06:31 +01:00
const initialState = {
loggedInChannelName : null,
loggedInChannelShortId: null,
publishToChannel : false,
publishStatus : null,
error : null,
file : null,
metadata : {
title : '',
claim : '',
thumbnail : '',
description: '',
license : '',
nsfw : '',
},
2018-01-09 02:06:31 +01:00
};
/*
Reducers describe how the application's state changes in response to actions
*/
export default function (state = initialState, action) {
switch (action.type) {
case FILE_SELECTED:
return Object.assign({}, state, {
file: action.file,
2018-01-09 02:06:31 +01:00
});
case FILE_CLEAR:
return initialState;
case METADATA_UPDATE:
console.log(`reducer for ${action.name} ${action.value}`);
return Object.assign({}, state, {
metadata: {
[action.name]: action.value,
},
})
2018-01-09 02:06:31 +01:00
default:
return state;
}
}