2016-03-22 10:22:46 +09:00
|
|
|
const PostList = ({results, currentUser, hasMore, ready, count, totalCount, loadMore, showViews = true}) => {
|
2016-02-15 22:33:44 +09:00
|
|
|
|
2016-02-17 17:22:32 +09:00
|
|
|
({PostItem, LoadMore, PostsLoading, NoPosts, NoMorePosts, PostViews} = Telescope.components);
|
2016-02-15 22:33:44 +09:00
|
|
|
|
2016-03-17 18:08:03 +09:00
|
|
|
if (!!results.length) {
|
2016-02-15 22:33:44 +09:00
|
|
|
return (
|
|
|
|
<div className="postList">
|
2016-03-22 10:22:46 +09:00
|
|
|
{showViews ? <PostViews /> : null}
|
2016-02-19 18:38:39 +09:00
|
|
|
<div className="post-list-content">
|
2016-03-17 18:08:03 +09:00
|
|
|
{results.map(post => <PostItem post={post} currentUser={currentUser} key={post._id}/>)}
|
2016-02-19 18:38:39 +09:00
|
|
|
</div>
|
2016-03-17 18:08:03 +09:00
|
|
|
{hasMore ? (ready ? <LoadMore loadMore={loadMore} count={count} totalCount={totalCount} /> : <PostsLoading/>) : <NoMorePosts/>}
|
2016-02-15 22:33:44 +09:00
|
|
|
</div>
|
|
|
|
)
|
2016-03-17 18:08:03 +09:00
|
|
|
} else if (!ready) {
|
2016-02-15 22:33:44 +09:00
|
|
|
return (
|
|
|
|
<div className="postList">
|
2016-03-22 10:22:46 +09:00
|
|
|
{showViews ? <PostViews /> : null}
|
2016-03-02 13:55:07 +09:00
|
|
|
<div className="post-list-content">
|
|
|
|
<PostsLoading/>
|
|
|
|
</div>
|
2016-02-15 22:33:44 +09:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
<div className="postList">
|
2016-03-22 10:22:46 +09:00
|
|
|
{showViews ? <PostViews /> : null}
|
2016-03-02 13:55:07 +09:00
|
|
|
<div className="post-list-content">
|
|
|
|
<NoPosts/>
|
|
|
|
</div>
|
2016-02-15 22:33:44 +09:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = PostList;
|