File size: 738 Bytes
f5071ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import PostIndex from './post_index';
import { requestFeedPosts } from '../../actions/post_actions';

const mapStateToProps = state => {
  const posts = [];
  const userId = state.session.currentUserId;

  for (let postId in state.entities.posts) {
    const post = state.entities.posts[postId];

    // filter posts
    // if (post.recipientId === userId) {}
    posts.push(post);
  }

  return {
    posts,
    userId,
    users: state.entities.users
  }
};

const mapDispatchToProps = dispatch => ({
  requestPosts: userId => dispatch(requestFeedPosts(userId))
});

export default withRouter(connect(mapStateToProps, mapDispatchToProps)(PostIndex));