Avoiding new comment button when a comment is posted.

This commit is contained in:
David Jay
2017-02-21 17:29:58 -05:00
parent 9149b737f5
commit ca107afb9b
2 changed files with 7 additions and 0 deletions
+2
View File
@@ -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}
@@ -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.');
}