import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { withList, withCurrentUser, Components, registerComponent, Utils } from 'meteor/vulcan:core';
import Comments from 'meteor/vulcan:comments';
const PostsCommentsThread = (props, /* context*/) => {
const {loading, terms: { postId }, results, totalCount} = props;
if (loading) {
return
} else {
const resultsClone = _.map(results, _.clone); // we don't want to modify the objects we got from props
const nestedComments = Utils.unflatten(resultsClone, {idProperty: '_id', parentIdProperty: 'parentCommentId'});
return (
{!!props.currentUser ?
:
}>
}
);
}
};
PostsCommentsThread.displayName = 'PostsCommentsThread';
PostsCommentsThread.propTypes = {
currentUser: PropTypes.object
};
const options = {
collection: Comments,
queryName: 'commentsListQuery',
fragmentName: 'CommentsList',
limit: 0,
};
registerComponent('PostsCommentsThread', PostsCommentsThread, [withList, options], withCurrentUser);