import 'jquery-scroll-lock'; import $ from 'jquery'; import _ from 'lodash'; import React from 'react'; import { connect } from 'react-redux'; import i18n from 'vj/utils/i18n'; 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, }); }, }); export default connect(mapStateToProps, mapDispatchToProps)(class MessagePadDialogueListContainer extends React.PureComponent { componentDidMount() { $(this.refs.list).scrollLock({ strict: true }); } render() { const orderedDialogues = _.orderBy( _.values(this.props.dialogues), (dialogue) => (_.maxBy(dialogue.messages, '_id') ? _.maxBy(dialogue.messages, '_id')._id : Number.POSITIVE_INFINITY), 'desc', ); return (
    {_.map(orderedDialogues, (dialogue) => ( this.props.handleClick(dialogue._id)} /> ))}
); } });