44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
import {bindActionCreators} from 'redux';
|
|
import {connect} from 'react-redux';
|
|
|
|
import {getStatusBarHeight} from 'app/selectors/device';
|
|
import {getTheme} from 'app/selectors/preferences';
|
|
|
|
import {selectPost} from 'mattermost-redux/actions/posts';
|
|
import {makeGetPostsForThread} from 'mattermost-redux/selectors/entities/posts';
|
|
import {getMyCurrentChannelMembership} from 'mattermost-redux/selectors/entities/channels';
|
|
|
|
import Thread from './thread';
|
|
|
|
function makeMapStateToProps() {
|
|
// Create a getPostsForThread selector for each instance of Thread so that each Thread
|
|
// is memoized correctly based on its own props
|
|
const getPostsForThread = makeGetPostsForThread();
|
|
|
|
return function mapStateToProps(state, ownProps) {
|
|
const posts = getPostsForThread(state, ownProps);
|
|
|
|
return {
|
|
...ownProps,
|
|
channelId: ownProps.channelId,
|
|
myMember: getMyCurrentChannelMembership(state),
|
|
rootId: ownProps.rootId,
|
|
posts,
|
|
statusBarHeight: getStatusBarHeight(state),
|
|
theme: getTheme(state)
|
|
};
|
|
};
|
|
}
|
|
|
|
function mapDispatchToProps(dispatch) {
|
|
return {
|
|
actions: bindActionCreators({
|
|
selectPost
|
|
}, dispatch)
|
|
};
|
|
}
|
|
|
|
export default connect(makeMapStateToProps, mapDispatchToProps)(Thread);
|