summaryrefslogtreecommitdiffstats
path: root/webapp/components/rhs_thread/index.js
blob: c4465cafd08de73462e777f1d43316686f09f536 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import {connect} from 'react-redux';
import {getPost, makeGetPostsForThread} from 'mattermost-redux/selectors/entities/posts';

import RhsThread from './rhs_thread.jsx';

function makeMapStateToProps() {
    const getPostsForThread = makeGetPostsForThread();

    return function mapStateToProps(state, ownProps) {
        const selected = getPost(state, state.views.rhs.selectedPostId);
        let posts = [];
        if (selected) {
            posts = getPostsForThread(state, {rootId: selected.id, channelId: selected.channel_id});
        }

        return {
            ...ownProps,
            selected,
            posts
        };
    };
}

export default connect(makeMapStateToProps)(RhsThread);