2018-01-09 02:46:17 +01:00
|
|
|
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,
|
2018-01-09 02:46:17 +01:00
|
|
|
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, {
|
2018-01-09 02:46:17 +01:00
|
|
|
file: action.file,
|
2018-01-09 02:06:31 +01:00
|
|
|
});
|
|
|
|
case FILE_CLEAR:
|
|
|
|
return initialState;
|
2018-01-09 02:46:17 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|