2018-02-13 03:18:56 +01:00
|
|
|
|
2018-02-02 03:42:03 +01:00
|
|
|
import { connect } from 'react-redux';
|
2018-02-13 03:18:56 +01:00
|
|
|
import { newChannelRequest, showNewChannel } from 'actions/show';
|
2018-02-02 03:42:03 +01:00
|
|
|
import View from './view';
|
|
|
|
|
|
|
|
const mapStateToProps = ({ show }) => {
|
2018-02-13 04:01:29 +01:00
|
|
|
// select request info
|
|
|
|
const requestId = show.request.id;
|
|
|
|
const requestType = show.request.type;
|
|
|
|
const requestChannelName = show.request.data.name;
|
|
|
|
const requestChannelId = show.request.data.id;
|
2018-02-13 03:18:56 +01:00
|
|
|
// select request
|
2018-02-13 04:01:29 +01:00
|
|
|
const previousRequest = show.channelRequests[show.request.id] || null;
|
|
|
|
// select channel info
|
|
|
|
let channel;
|
|
|
|
if (previousRequest) {
|
|
|
|
const channelKey = `c#${previousRequest.name}#${previousRequest.longId}`;
|
|
|
|
channel = show.channelList[channelKey] || null;
|
2018-02-13 03:18:56 +01:00
|
|
|
}
|
2018-02-13 04:01:29 +01:00
|
|
|
return {
|
|
|
|
requestId,
|
|
|
|
requestType,
|
|
|
|
requestChannelName,
|
|
|
|
requestChannelId,
|
|
|
|
previousRequest,
|
|
|
|
channel,
|
|
|
|
};
|
2018-02-02 03:42:03 +01:00
|
|
|
};
|
|
|
|
|
2018-02-03 03:16:18 +01:00
|
|
|
const mapDispatchToProps = dispatch => {
|
|
|
|
return {
|
2018-02-09 01:42:13 +01:00
|
|
|
// request
|
2018-02-13 03:18:56 +01:00
|
|
|
onNewChannelRequest (requestId, requestChannelName, requestChannelId) {
|
|
|
|
dispatch(newChannelRequest(requestId, requestChannelName, requestChannelId));
|
2018-02-08 19:59:49 +01:00
|
|
|
},
|
2018-02-09 01:42:13 +01:00
|
|
|
// show channel
|
2018-02-13 03:18:56 +01:00
|
|
|
onShowNewChannel: (name, shortId, longId) => {
|
|
|
|
dispatch(showNewChannel(name, shortId, longId));
|
2018-02-08 07:22:17 +01:00
|
|
|
},
|
2018-02-03 03:16:18 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(View);
|