import React from 'react'; import _ from 'lodash'; import { connect } from 'react-redux'; import 'jquery-scroll-lock'; import ListItem from './DialogueListItemComponent'; const mapStateToProps = (state) => ({ activeId: state.activeId, dialogues: state.dialogues, }); const mapDispatchToProps = (dispatch) => ({ handleClick(id) { dispatch({ type: 'DIALOGUES_SWITCH_TO', payload: id, }); }, }); @connect(mapStateToProps, mapDispatchToProps) export default class MessagePadDialogueListContainer extends React.PureComponent { componentDidMount() { $(this.refs.list).scrollLock({ strict: true }); } render() { const orderedDialogues = _.orderBy( _.values(this.props.dialogues), (dialogue) => (dialogue.isPlaceholder ? Number.POSITIVE_INFINITY : _.maxBy(dialogue.reply, 'at').at), 'desc', ); return (
    {_.map(orderedDialogues, (dialogue) => ( this.props.handleClick(dialogue._id)} /> ))}
); } }