2018-10-08 06:44:58 +09:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import Conversation from '../components/conversation';
|
2018-10-19 08:47:29 +09:00
|
|
|
import { markConversationRead } from '../../../actions/conversations';
|
2018-10-08 06:44:58 +09:00
|
|
|
|
|
|
|
const mapStateToProps = (state, { conversationId }) => {
|
|
|
|
const conversation = state.getIn(['conversations', 'items']).find(x => x.get('id') === conversationId);
|
|
|
|
const lastStatus = state.getIn(['statuses', conversation.get('last_status')], null);
|
|
|
|
|
|
|
|
return {
|
|
|
|
accounts: conversation.get('accounts').map(accountId => state.getIn(['accounts', accountId], null)),
|
2018-10-19 08:47:29 +09:00
|
|
|
unread: conversation.get('unread'),
|
2018-10-08 06:44:58 +09:00
|
|
|
lastStatus,
|
|
|
|
lastAccount: lastStatus === null ? null : state.getIn(['accounts', lastStatus.get('account')], null),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-10-19 08:47:29 +09:00
|
|
|
const mapDispatchToProps = (dispatch, { conversationId }) => ({
|
|
|
|
markRead: () => dispatch(markConversationRead(conversationId)),
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Conversation);
|