2018-01-16 20:38:37 +01:00
|
|
|
import * as actions from '../constants/action_types';
|
2018-01-09 02:06:31 +01:00
|
|
|
|
|
|
|
const initialState = {
|
2018-01-10 03:25:38 +01:00
|
|
|
loggedInChannel: {
|
|
|
|
name : null,
|
|
|
|
shortId: null,
|
|
|
|
longId : null,
|
|
|
|
},
|
2018-01-10 20:26:01 +01:00
|
|
|
publishInChannel: false,
|
2018-01-12 00:37:32 +01:00
|
|
|
status : {
|
|
|
|
status : null,
|
|
|
|
message: null,
|
|
|
|
},
|
2018-01-12 23:27:34 +01:00
|
|
|
error: {
|
2018-01-15 18:59:23 +01:00
|
|
|
file : null,
|
|
|
|
url : null,
|
|
|
|
publishSubmit: null,
|
2018-01-12 23:27:34 +01:00
|
|
|
},
|
2018-01-12 00:37:32 +01:00
|
|
|
file : null,
|
|
|
|
claim : '',
|
|
|
|
metadata: {
|
2018-01-09 02:46:17 +01:00
|
|
|
title : '',
|
|
|
|
thumbnail : '',
|
|
|
|
description: '',
|
|
|
|
license : '',
|
2018-01-10 22:10:08 +01:00
|
|
|
nsfw : false,
|
2018-01-09 02:46:17 +01:00
|
|
|
},
|
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) {
|
2018-01-16 20:38:37 +01:00
|
|
|
case actions.FILE_SELECTED:
|
2018-01-09 02:06:31 +01:00
|
|
|
return Object.assign({}, state, {
|
2018-01-09 02:46:17 +01:00
|
|
|
file: action.file,
|
2018-01-09 02:06:31 +01:00
|
|
|
});
|
2018-01-16 20:38:37 +01:00
|
|
|
case actions.FILE_CLEAR:
|
2018-01-09 02:06:31 +01:00
|
|
|
return initialState;
|
2018-01-16 20:38:37 +01:00
|
|
|
case actions.METADATA_UPDATE:
|
2018-01-09 02:46:17 +01:00
|
|
|
return Object.assign({}, state, {
|
2018-01-10 22:10:08 +01:00
|
|
|
metadata: Object.assign({}, state.metadata, {
|
2018-01-09 02:46:17 +01:00
|
|
|
[action.name]: action.value,
|
2018-01-10 22:10:08 +01:00
|
|
|
}),
|
2018-01-10 03:25:38 +01:00
|
|
|
});
|
2018-01-16 20:38:37 +01:00
|
|
|
case actions.CLAIM_UPDATE:
|
2018-01-10 03:25:38 +01:00
|
|
|
return Object.assign({}, state, {
|
|
|
|
claim: action.value,
|
|
|
|
});
|
2018-01-16 20:38:37 +01:00
|
|
|
case actions.CHANNEL_UPDATE:
|
2018-01-10 03:25:38 +01:00
|
|
|
return Object.assign({}, state, {
|
|
|
|
loggedInChannel: {
|
|
|
|
name : action.name,
|
|
|
|
shortId: action.shortId,
|
|
|
|
longId : action.longId,
|
|
|
|
},
|
|
|
|
});
|
2018-01-16 20:38:37 +01:00
|
|
|
case actions.SET_PUBLISH_IN_CHANNEL:
|
2018-01-10 03:25:38 +01:00
|
|
|
return Object.assign({}, state, {
|
2018-01-11 21:51:38 +01:00
|
|
|
publishInChannel: action.channel,
|
2018-01-10 03:25:38 +01:00
|
|
|
});
|
2018-01-16 20:38:37 +01:00
|
|
|
case actions.PUBLISH_STATUS_UPDATE:
|
2018-01-11 21:51:38 +01:00
|
|
|
return Object.assign({}, state, {
|
2018-01-12 23:27:34 +01:00
|
|
|
status: Object.assign({}, state.status, {
|
2018-01-12 00:37:32 +01:00
|
|
|
status : action.status,
|
|
|
|
message: action.message,
|
|
|
|
}),
|
|
|
|
});
|
2018-01-16 20:38:37 +01:00
|
|
|
case actions.ERROR_UPDATE:
|
2018-01-12 23:27:34 +01:00
|
|
|
return Object.assign({}, state, {
|
|
|
|
error: Object.assign({}, state.error, {
|
|
|
|
[action.name]: action.value,
|
|
|
|
}),
|
|
|
|
});
|
2018-01-09 02:06:31 +01:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|