From ca107afb9b06dad9074860f2734364241eb4ca22 Mon Sep 17 00:00:00 2001 From: David Jay Date: Tue, 21 Feb 2017 17:29:58 -0500 Subject: [PATCH] Avoiding new comment button when a comment is posted. --- client/coral-embed-stream/src/Embed.js | 2 ++ client/coral-plugin-commentbox/CommentBox.js | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index 6ff153a52..1c7898afb 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -134,6 +134,8 @@ class Embed extends Component { postItem={this.props.postItem} appendItemArray={this.props.appendItemArray} updateItem={this.props.updateItem} + updateCountCache={this.props.updateCountCache} + countCache={countCache[asset.id]} assetId={asset.id} premod={asset.settings.moderation} isReply={false} diff --git a/client/coral-plugin-commentbox/CommentBox.js b/client/coral-plugin-commentbox/CommentBox.js index 344ade150..3d895df07 100644 --- a/client/coral-plugin-commentbox/CommentBox.js +++ b/client/coral-plugin-commentbox/CommentBox.js @@ -29,6 +29,8 @@ class CommentBox extends Component { commentPostedHandler, postItem, assetId, + updateCountCache, + countCache, parentId, addNotification, authorId @@ -44,14 +46,17 @@ class CommentBox extends Component { if (this.props.charCount && this.state.body.length > this.props.charCount) { return; } + updateCountCache(assetId, countCache + 1); postItem(comment, 'comments') .then(({data}) => { const postedComment = data.createComment.comment; if (postedComment.status === 'REJECTED') { addNotification('error', lang.t('comment-post-banned-word')); + updateCountCache(assetId, countCache); } else if (postedComment.status === 'PREMOD') { addNotification('success', lang.t('comment-post-notif-premod')); + updateCountCache(assetId, countCache); } else { addNotification('success', 'Your comment has been posted.'); }