import Telescope, { Components, registerComponent } from 'meteor/nova:lib';
import React from 'react';
import {FormattedMessage } from 'react-intl';
import { ModalTrigger, withList } from 'meteor/nova:core';
import { withCurrentUser } from 'meteor/nova:core';
import Comments from 'meteor/nova:comments';
import gql from 'graphql-tag';
const PostsCommentsThread = (props, context) => {
const {loading, terms: { postId }, results} = props;
if (loading) {
return
} else {
const commentCount = results.length;
const resultsClone = _.map(results, _.clone); // we don't want to modify the objects we got from props
const nestedComments = Telescope.utils.unflatten(resultsClone, '_id', 'parentCommentId');
return (
{ props.currentUser ?
:
}>
}
);
}
};
PostsCommentsThread.displayName = "PostsCommentsThread";
PostsCommentsThread.propTypes = {
currentUser: React.PropTypes.object
};
PostsCommentsThread.fragment = gql`
fragment commentsListFragment on Comment {
_id
postId
parentCommentId
topLevelCommentId
body
htmlBody
postedAt
user {
_id
__displayName
__emailHash
__slug
}
userId
}
`;
const options = {
collection: Comments,
queryName: 'commentsListQuery',
fragment: PostsCommentsThread.fragment,
};
registerComponent('PostsCommentsThread', PostsCommentsThread, withCurrentUser, withList(options));