2016-03-30 09:24:52 +09:00
|
|
|
import React from 'react';
|
|
|
|
|
2016-03-17 17:48:25 +09:00
|
|
|
const CommentList = ({results, currentUser, hasMore, ready, count, totalCount, loadMore}) => {
|
2016-02-16 16:12:13 +09:00
|
|
|
|
2016-04-03 15:56:12 +09:00
|
|
|
({LoadMore, Loading, NoPosts, NoMorePosts, CommentNode} = Telescope.components);
|
2016-02-18 17:53:04 +09:00
|
|
|
|
2016-03-17 17:48:25 +09:00
|
|
|
if (!!results.length) {
|
2016-02-16 16:12:13 +09:00
|
|
|
return (
|
2016-04-03 15:56:12 +09:00
|
|
|
<div className="comment-list">
|
2016-03-17 17:48:25 +09:00
|
|
|
{results.map(comment => <CommentNode comment={comment} key={comment._id} currentUser={currentUser}/>)}
|
2016-04-03 15:56:12 +09:00
|
|
|
{hasMore ? (ready ? <LoadMore loadMore={loadMore} count={count} totalCount={totalCount} /> : <Loading/>) : <NoMorePosts/>}
|
2016-02-16 16:12:13 +09:00
|
|
|
</div>
|
|
|
|
)
|
2016-03-17 17:48:25 +09:00
|
|
|
} else if (!ready) {
|
2016-02-16 16:12:13 +09:00
|
|
|
return (
|
2016-04-03 15:56:12 +09:00
|
|
|
<div className="comment-list">
|
|
|
|
<Loading/>
|
2016-02-16 16:12:13 +09:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
return (
|
2016-04-03 15:56:12 +09:00
|
|
|
<div className="comment-list">
|
|
|
|
<p>No comments to display.</p>
|
2016-02-16 16:12:13 +09:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = CommentList;
|