2018-01-24 20:24:49 +01:00
|
|
|
import * as actions from 'constants/publish_action_types';
|
2018-01-24 21:02:40 +01:00
|
|
|
import { LOGIN } from 'constants/publish_channel_select_states';
|
2018-02-06 03:14:12 +01:00
|
|
|
const { publish } = require('../../config/speechConfig.js');
|
2018-01-18 18:33:26 +01:00
|
|
|
|
|
|
|
const initialState = {
|
2018-01-20 01:03:49 +01:00
|
|
|
publishInChannel : false,
|
2018-01-24 21:02:40 +01:00
|
|
|
selectedChannel : LOGIN,
|
2018-01-20 01:03:49 +01:00
|
|
|
showMetadataInputs: false,
|
|
|
|
status : {
|
2018-01-18 18:33:26 +01:00
|
|
|
status : null,
|
|
|
|
message: null,
|
|
|
|
},
|
|
|
|
error: {
|
|
|
|
file : null,
|
|
|
|
url : null,
|
2018-01-24 21:32:24 +01:00
|
|
|
channel : null,
|
2018-01-18 18:33:26 +01:00
|
|
|
publishSubmit: null,
|
|
|
|
},
|
|
|
|
file : null,
|
|
|
|
claim : '',
|
|
|
|
metadata: {
|
|
|
|
title : '',
|
|
|
|
thumbnail : '',
|
|
|
|
description: '',
|
|
|
|
license : '',
|
|
|
|
nsfw : false,
|
|
|
|
},
|
2018-02-06 03:14:12 +01:00
|
|
|
thumbnail: {
|
|
|
|
channel : publish.thumbnailChannel,
|
|
|
|
claim : null,
|
|
|
|
url : null,
|
|
|
|
potentialFiles: [], // should be named 'thumbnailFiles' or something
|
|
|
|
selectedFile : null,
|
|
|
|
},
|
2018-01-18 18:33:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Reducers describe how the application's state changes in response to actions
|
|
|
|
*/
|
|
|
|
|
|
|
|
export default function (state = initialState, action) {
|
|
|
|
switch (action.type) {
|
|
|
|
case actions.FILE_SELECTED:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
file: action.file,
|
|
|
|
});
|
|
|
|
case actions.FILE_CLEAR:
|
|
|
|
return initialState;
|
|
|
|
case actions.METADATA_UPDATE:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
metadata: Object.assign({}, state.metadata, {
|
|
|
|
[action.name]: action.value,
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
case actions.CLAIM_UPDATE:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
claim: action.value,
|
|
|
|
});
|
|
|
|
case actions.SET_PUBLISH_IN_CHANNEL:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
publishInChannel: action.channel,
|
|
|
|
});
|
|
|
|
case actions.PUBLISH_STATUS_UPDATE:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
status: Object.assign({}, state.status, {
|
|
|
|
status : action.status,
|
|
|
|
message: action.message,
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
case actions.ERROR_UPDATE:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
error: Object.assign({}, state.error, {
|
|
|
|
[action.name]: action.value,
|
|
|
|
}),
|
|
|
|
});
|
2018-01-19 19:16:55 +01:00
|
|
|
case actions.SELECTED_CHANNEL_UPDATE:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
selectedChannel: action.value,
|
|
|
|
});
|
2018-01-20 01:03:49 +01:00
|
|
|
case actions.TOGGLE_METADATA_INPUTS:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
showMetadataInputs: action.value,
|
|
|
|
});
|
2018-02-06 03:14:12 +01:00
|
|
|
case actions.THUMBNAIL_CLAIM_UPDATE:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
thumbnail: Object.assign({}, state.thumbnail, {
|
|
|
|
claim: action.claim,
|
|
|
|
url : action.url,
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
case actions.THUMBNAIL_FILES_UPDATE:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
thumbnail: Object.assign({}, state.thumbnail, {
|
|
|
|
potentialFiles: [action.fileOne, action.fileTwo, action.fileThree],
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
case actions.THUMBNAIL_FILE_SELECT:
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
thumbnail: Object.assign({}, state.thumbnail, {
|
|
|
|
selectedFile: action.file,
|
|
|
|
}),
|
|
|
|
});
|
2018-01-18 18:33:26 +01:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|