{replies.length !== 0 && (
)}
{ !showEditor && isLoggedIn && (
)}
{ showEditor && isLoggedIn && (
)}
);
}
render() {
const topLevelComments = [];
const allReplies = [];
const comments = this.props.commentContainer.state.comments;
comments.forEach((comment) => {
if (comment.replyTo === undefined) {
// comment is not a reply
topLevelComments.push(comment);
}
else {
// comment is a reply
allReplies.push(comment);
}
});
return (
{ topLevelComments.map((topLevelComment) => {
// get related replies
const replies = this.getRepliesFor(topLevelComment, allReplies);
return this.renderThread(topLevelComment, replies);
}) }
);
}
}
/**
* Wrapper component for using unstated
*/
const PageCommentsWrapper = (props) => {
return createSubscribedElement(PageComments, props, [AppContainer, PageContainer, CommentContainer]);
};
PageComments.propTypes = {
appContainer: PropTypes.instanceOf(AppContainer).isRequired,
pageContainer: PropTypes.instanceOf(PageContainer).isRequired,
commentContainer: PropTypes.instanceOf(CommentContainer).isRequired,
};
export default withTranslation()(PageCommentsWrapper);