From acd57e4f68be7717844ee664479838fa12fc2dca Mon Sep 17 00:00:00 2001 From: David Jay Date: Fri, 9 Dec 2016 16:15:33 -0500 Subject: [PATCH] Avoiding double-posting. --- client/coral-embed-stream/src/CommentStream.js | 2 +- client/coral-plugin-flags/FlagButton.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/client/coral-embed-stream/src/CommentStream.js b/client/coral-embed-stream/src/CommentStream.js index d703e8512..49825480e 100644 --- a/client/coral-embed-stream/src/CommentStream.js +++ b/client/coral-embed-stream/src/CommentStream.js @@ -210,7 +210,7 @@ class CommentStream extends Component { addNotification={this.props.addNotification} id={replyId} author_id={comment.author_id} - flag={this.props.items.actions[reply.flag]} + flag={actions[reply.flag]} postAction={this.props.postAction} showSignInDialog={this.props.showSignInDialog} deleteAction={this.props.deleteAction} diff --git a/client/coral-plugin-flags/FlagButton.js b/client/coral-plugin-flags/FlagButton.js index bb96c3cdf..e36d96ab4 100644 --- a/client/coral-plugin-flags/FlagButton.js +++ b/client/coral-plugin-flags/FlagButton.js @@ -14,7 +14,8 @@ class FlagButton extends Component { itemType: '', detail: '', otherText: '', - step: 0 + step: 0, + posted: false } onReportClick = () => { @@ -28,7 +29,7 @@ class FlagButton extends Component { onPopupContinue = () => { const {postAction, addItem, updateItem, flag, id, author_id} = this.props; - const {itemType, field, detail, step, otherText} = this.state; + const {itemType, field, detail, step, otherText, posted} = this.state; if (step + 1 >= this.getPopupMenu.length) { this.setState({showMenu: false}); @@ -36,7 +37,7 @@ class FlagButton extends Component { this.setState({step: step + 1}); } - if (itemType && detail) { + if (itemType && detail && !posted) { const updatedDetail = otherText || detail; const item_id = itemType === 'comments' ? id : author_id; const action = { @@ -49,6 +50,7 @@ class FlagButton extends Component { let id = `${action.action_type}_${action.item_id}`; addItem({id, current_user: action, count: flag ? flag.count + 1 : 1}, 'actions'); updateItem(action.item_id, action.action_type, id, action.item_type); + this.setState({posted: true}); }); } }