2019-05-17 20:21:07 +02:00
|
|
|
// @flow
|
2019-06-27 01:59:27 +02:00
|
|
|
import React, { useEffect } from 'react';
|
|
|
|
import Comment from 'component/comment';
|
2019-05-17 20:21:07 +02:00
|
|
|
|
2019-06-27 01:59:27 +02:00
|
|
|
type Props = {
|
2019-06-12 16:53:27 +02:00
|
|
|
comments: Array<any>,
|
2019-06-27 01:59:27 +02:00
|
|
|
fetchComments: string => void,
|
2019-05-17 20:21:07 +02:00
|
|
|
uri: string,
|
|
|
|
};
|
|
|
|
|
2019-06-27 01:59:27 +02:00
|
|
|
function CommentList(props: Props) {
|
|
|
|
const { fetchComments, uri, comments } = props;
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
fetchComments(uri);
|
|
|
|
}, [fetchComments, uri]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ul className="comments">
|
|
|
|
{comments &&
|
|
|
|
comments.map(comment => {
|
|
|
|
return (
|
|
|
|
<Comment
|
2019-07-17 22:56:36 +02:00
|
|
|
authorUri={comment.channel_url}
|
2019-06-27 01:59:27 +02:00
|
|
|
author={comment.channel_name}
|
|
|
|
claimId={comment.channel_id}
|
|
|
|
commentId={comment.comment_id}
|
|
|
|
key={comment.channel_id + comment.comment_id}
|
|
|
|
message={comment.comment}
|
|
|
|
parentId={comment.parent_id || null}
|
|
|
|
timePosted={comment.timestamp * 1000}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</ul>
|
|
|
|
);
|
2019-05-17 20:21:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export default CommentList;
|