spee.ch/react/containers/ShowChannel/index.js

37 lines
1 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
2018-02-14 01:51:59 +01:00
import { newChannelRequest } from 'actions/show';
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;
// select request
2018-02-13 04:01:29 +01:00
const previousRequest = show.channelRequests[show.request.id] || null;
2018-02-14 01:51:59 +01:00
// select channel
2018-02-13 04:01:29 +01:00
let channel;
if (previousRequest) {
const channelKey = `c#${previousRequest.name}#${previousRequest.longId}`;
channel = show.channelList[channelKey] || null;
}
2018-02-13 04:01:29 +01:00
return {
requestId,
requestType,
requestChannelName,
requestChannelId,
channel,
};
};
2018-02-03 03:16:18 +01:00
const mapDispatchToProps = dispatch => {
return {
onNewChannelRequest (requestId, requestChannelName, requestChannelId) {
dispatch(newChannelRequest(requestId, requestChannelName, requestChannelId));
},
2018-02-03 03:16:18 +01:00
};
};
export default connect(mapStateToProps, mapDispatchToProps)(View);