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