2019-03-20 17:42:28 +00:00
|
|
|
import { connect } from 'react-redux';
|
2019-08-09 00:46:49 +00:00
|
|
|
|
2019-03-20 17:42:28 +00:00
|
|
|
import { mapDispatchToProps } from '../actions';
|
|
|
|
import { StateType } from '../reducer';
|
|
|
|
|
2019-08-09 00:46:49 +00:00
|
|
|
import { TimelineItem } from '../../components/conversation/TimelineItem';
|
2019-03-20 17:42:28 +00:00
|
|
|
import { getIntl } from '../selectors/user';
|
2019-11-07 21:36:16 +00:00
|
|
|
import {
|
|
|
|
getMessageSelector,
|
|
|
|
getSelectedMessage,
|
|
|
|
} from '../selectors/conversations';
|
2019-03-20 17:42:28 +00:00
|
|
|
|
|
|
|
type ExternalProps = {
|
|
|
|
id: string;
|
2019-11-07 21:36:16 +00:00
|
|
|
conversationId: string;
|
2019-03-20 17:42:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const mapStateToProps = (state: StateType, props: ExternalProps) => {
|
2019-11-07 21:36:16 +00:00
|
|
|
const { id, conversationId } = props;
|
2019-03-20 17:42:28 +00:00
|
|
|
|
|
|
|
const messageSelector = getMessageSelector(state);
|
2019-05-31 22:42:01 +00:00
|
|
|
const item = messageSelector(id);
|
2019-03-20 17:42:28 +00:00
|
|
|
|
2019-11-07 21:36:16 +00:00
|
|
|
const selectedMessage = getSelectedMessage(state);
|
|
|
|
const isSelected = Boolean(selectedMessage && id === selectedMessage.id);
|
|
|
|
|
2019-03-20 17:42:28 +00:00
|
|
|
return {
|
2019-05-31 22:42:01 +00:00
|
|
|
item,
|
2019-11-07 21:36:16 +00:00
|
|
|
id,
|
|
|
|
conversationId,
|
|
|
|
isSelected,
|
2019-03-20 17:42:28 +00:00
|
|
|
i18n: getIntl(state),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const smart = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
|
|
|
|
export const SmartTimelineItem = smart(TimelineItem);
|