{"size": 629, "ext": "js", "max_stars_repo_path": "src/modules/messages/components/list/connector.js", "max_stars_repo_name": "chebugram/chebugram", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/modules/messages/components/list/connector.js", "max_issues_repo_name": "chebugram/chebugram", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/modules/messages/components/list/connector.js", "max_forks_repo_name": "chebugram/chebugram", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.6896551724, "max_line_length": 87, "alphanum_fraction": 0.6772655008}
import { selectMessagesForConversation } from '../../selectors';
import { connect } from 'react-redux';

import {
	CONVERSATION_TYPE__CHANNEL,
} from '../../../conversations/constants';

import {
	selectContacts,
} from '../../../contacts/selectors';

import Messages from './messages';


export default connect((state, { id, type }) => {
	const messages = (selectMessagesForConversation(state, { conversationId: id }) || []);

	const result = {
		messages: messages.slice(-50),
	};

	// TODO: Move to map
	if ( type === CONVERSATION_TYPE__CHANNEL ) {
		result.contacts = selectContacts(state);
	}

	return result;
})(Messages);
