2016-03-30 09:24:52 +09:00
|
|
|
import React from 'react';
|
|
|
|
|
2016-03-24 18:17:35 +09:00
|
|
|
const PostList = ({results, currentUser, hasMore, ready, count, totalCount, loadMore, showHeader = true}) => {
|
2016-02-15 22:33:44 +09:00
|
|
|
|
2016-03-24 16:03:30 +09:00
|
|
|
// console.log(results);
|
|
|
|
// console.log(ready);
|
|
|
|
|
2016-03-24 18:17:35 +09:00
|
|
|
({PostItem, LoadMore, PostsLoading, NoPosts, NoMorePosts, PostListHeader} = 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-24 18:17:35 +09:00
|
|
|
{showHeader ? <PostListHeader /> : 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-24 18:17:35 +09:00
|
|
|
{showHeader ? <PostListHeader /> : 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-24 18:17:35 +09:00
|
|
|
{showHeader ? <PostListHeader /> : 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;
|