From 5e13af82824d4196ba7d5a3715415fa6245c805c Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 18 Aug 2017 18:42:41 +0700 Subject: [PATCH] Fix emit showMoreReplies event --- client/coral-embed-stream/src/components/Comment.js | 10 ++++++++-- client/coral-embed-stream/src/components/Stream.js | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/client/coral-embed-stream/src/components/Comment.js b/client/coral-embed-stream/src/components/Comment.js index 6c231f4ae..df29ff6ff 100644 --- a/client/coral-embed-stream/src/components/Comment.js +++ b/client/coral-embed-stream/src/components/Comment.js @@ -180,6 +180,9 @@ export default class Comment extends React.Component { // edit a comment, passed (id, asset_id, { body }) editComment: PropTypes.func, + + // emit custom events + emit: PropTypes.func.isRequired, } editComment = (...args) => { @@ -207,7 +210,7 @@ export default class Comment extends React.Component { } loadNewReplies = () => { - const {replies, replyCount, id} = this.props.comment; + const {comment: {replies, replyCount, id}, emit} = this.props; if (replyCount > replies.nodes.length) { this.setState({loadingState: 'loading'}); this.props.loadMore(id) @@ -221,10 +224,11 @@ export default class Comment extends React.Component { this.setState({loadingState: 'error'}); forEachError(error, ({msg}) => {this.props.addNotification('error', msg);}); }); + emit('ui.Comment.showMoreReplies', {id}); return; } this.setState(resetCursors); - this.props.emit('ui.Comment.showMoreReplies'); + emit('ui.Comment.showMoreReplies', {id}); }; showReplyBox = () => { @@ -315,6 +319,7 @@ export default class Comment extends React.Component { showSignInDialog, liveUpdates, commentIsIgnored, + emit, commentClassNames = [] } = this.props; @@ -568,6 +573,7 @@ export default class Comment extends React.Component { reactKey={reply.id} key={reply.id} comment={reply} + emit={emit} />; })} diff --git a/client/coral-embed-stream/src/components/Stream.js b/client/coral-embed-stream/src/components/Stream.js index 7b9e5f566..8fe373859 100644 --- a/client/coral-embed-stream/src/components/Stream.js +++ b/client/coral-embed-stream/src/components/Stream.js @@ -99,7 +99,8 @@ class Stream extends React.Component { loadMoreComments, viewAllComments, auth: {loggedIn, user}, - editName + editName, + emit, } = this.props; const {keepCommentBox} = this.state; const open = !asset.isClosed; @@ -234,6 +235,7 @@ class Stream extends React.Component { charCountEnable={asset.settings.charCountEnable} maxCharCount={asset.settings.charCount} editComment={editComment} + emit={emit} liveUpdates={true} /> @@ -292,7 +294,7 @@ class Stream extends React.Component { charCountEnable={asset.settings.charCountEnable} maxCharCount={asset.settings.charCount} editComment={editComment} - emit={this.props.emit} + emit={emit} />