diff --git a/client/coral-embed-stream/src/Comment.js b/client/coral-embed-stream/src/Comment.js index bbc8b6e00..1310358fe 100644 --- a/client/coral-embed-stream/src/Comment.js +++ b/client/coral-embed-stream/src/Comment.js @@ -9,12 +9,12 @@ import React, {PropTypes} from 'react'; import PermalinkButton from 'coral-plugin-permalinks/PermalinkButton'; -// import AuthorName from '../../coral-plugin-author-name/AuthorName'; -import Content from '../../coral-plugin-commentcontent/CommentContent'; -import PubDate from '../../coral-plugin-pubdate/PubDate'; +import AuthorName from 'coral-plugin-author-name/AuthorName'; +import Content from 'coral-plugin-commentcontent/CommentContent'; +import PubDate from 'coral-plugin-pubdate/PubDate'; import {ReplyBox, ReplyButton} from 'coral-plugin-replies'; -import FlagComment from '../../coral-plugin-flags/FlagComment'; -import LikeButton from '../../coral-plugin-likes/LikeButton'; +import FlagComment from 'coral-plugin-flags/FlagComment'; +import LikeButton from 'coral-plugin-likes/LikeButton'; const getAction = (type, comment) => comment.actions.filter((a) => a.type === type)[0]; @@ -26,6 +26,7 @@ class Comment extends React.Component { } static propTypes = { + refetch: PropTypes.func.isRequired, showSignInDialog: PropTypes.func.isRequired, postAction: PropTypes.func.isRequired, deleteAction: PropTypes.func.isRequired, @@ -62,10 +63,12 @@ class Comment extends React.Component { render () { const { comment, + parentId, currentUser, asset, depth, postItem, + refetch, addNotification, showSignInDialog, postAction, @@ -81,7 +84,7 @@ class Comment extends React.Component { id={`c_${comment.id}`} style={{marginLeft: depth * 30}}>
- {/* */} + currentUser={currentUser}/> @@ -100,10 +101,9 @@ class Comment extends React.Component { ?
{ - console.log('reply button click'); this.setState({replyBoxVisible: !this.state.replyBoxVisible}); }} - parentCommentId={comment.id} + parentCommentId={parentId || comment.id} currentUserId={currentUser.id} banned={false} /> + replyPostedHandler={() => { + console.log('replyPostedHandler'); + this.setState({replyBoxVisible: false}); + refetch(); + }} + parentId={parentId || comment.id} + addNotification={addNotification} + authorId={currentUser.id} + postItem={postItem} + assetId={asset.id} /> : null } { comment.replies && comment.replies.map(reply => { return { + const commentId = hash.replace('#', 'c_'); + let count = 0; + const interval = setInterval(() => { + if (document.getElementById(commentId)) { + window.clearInterval(interval); + pym.scrollParentToChildEl(commentId); + } + + if (++count > 100) { // ~10 seconds + // give up waiting for the comments to load. + // it would be weird for the page to jump after that long. + window.clearInterval(interval); + } + }, 100); + }); + + } + componentWillReceiveProps (nextProps) { const {loadAsset} = this.props if(!isEqual(nextProps.data.asset, this.props.data.asset)) { loadAsset(nextProps.data.asset) } - } + } render () { const {activeTab} = this.state; @@ -89,6 +120,7 @@ class Embed extends Component { { user ? { +const Stream = ({ + comments, + currentUser, + asset, + postItem, + addNotification, + postAction, + deleteAction, + showSignInDialog, + refetch +}) => { return (
{ comments.map(comment => { return - {author && author.displayName} + {author && author.name} { showTooltip &&
{author.settings.bio} diff --git a/client/coral-plugin-commentbox/CommentBox.js b/client/coral-plugin-commentbox/CommentBox.js index 40ffbf277..409a0ea4d 100644 --- a/client/coral-plugin-commentbox/CommentBox.js +++ b/client/coral-plugin-commentbox/CommentBox.js @@ -11,6 +11,7 @@ class CommentBox extends Component { // updateItem: PropTypes.func, // comments: PropTypes.array, + replyPostedHandler: PropTypes.func, postItem: PropTypes.func.isRequired, assetId: PropTypes.string.isRequired, parentId: PropTypes.string, @@ -31,6 +32,7 @@ class CommentBox extends Component { // child_id, // updateItem, // appendItemArray, + replyPostedHandler, postItem, assetId, parentId, @@ -45,8 +47,6 @@ class CommentBox extends Component { parent_id: parentId }; - console.log('CommentBox.parentId', parentId); - // let related; // let parent_type; // if (parent_id) { @@ -78,6 +78,10 @@ class CommentBox extends Component { // appendItemArray(parent_id || id, related, commentId, !parent_id, parent_type); addNotification('success', 'Your comment has been posted.'); } + + if (replyPostedHandler) { + replyPostedHandler(); + } }) .catch((err) => console.error(err)); this.setState({body: ''}); diff --git a/client/coral-plugin-replies/ReplyBox.js b/client/coral-plugin-replies/ReplyBox.js index fe9987bf7..ac1a702f8 100644 --- a/client/coral-plugin-replies/ReplyBox.js +++ b/client/coral-plugin-replies/ReplyBox.js @@ -3,9 +3,10 @@ import CommentBox from '../coral-plugin-commentbox/CommentBox'; const name = 'coral-plugin-replies'; -const ReplyBox = ({styles, postItem, assetId, authorId, addNotification, parentId}) => ( +const ReplyBox = ({styles, postItem, assetId, authorId, addNotification, parentId, replyPostedHandler}) => (