close reply box when comment is posted

This commit is contained in:
Riley Davis
2017-01-24 10:55:51 -07:00
parent c4e1c1ae44
commit 4e8306bcc9
4 changed files with 14 additions and 8 deletions
+5 -1
View File
@@ -135,7 +135,11 @@ class Comment extends React.Component {
{
this.state.replyBoxVisible
? <ReplyBox
refetch={refetch}
replyPostedHandler={() => {
console.log('replyPostedHandler');
this.setState({replyBoxVisible: false});
refetch();
}}
parentId={parentId || comment.id}
addNotification={addNotification}
authorId={currentUser.id}
@@ -1,7 +1,6 @@
import React from 'react';
const Notification = (props) => {
console.log(props);
if (props.notification.text) {
setTimeout(() => {
props.clearNotification();
+6 -3
View File
@@ -11,7 +11,7 @@ class CommentBox extends Component {
// updateItem: PropTypes.func,
// comments: PropTypes.array,
refetch: PropTypes.func.isRequired,
replyPostedHandler: PropTypes.func,
postItem: PropTypes.func.isRequired,
assetId: PropTypes.string.isRequired,
parentId: PropTypes.string,
@@ -32,11 +32,11 @@ class CommentBox extends Component {
// child_id,
// updateItem,
// appendItemArray,
replyPostedHandler,
postItem,
assetId,
parentId,
addNotification,
refetch,
authorId
} = this.props;
@@ -78,7 +78,10 @@ class CommentBox extends Component {
// appendItemArray(parent_id || id, related, commentId, !parent_id, parent_type);
addNotification('success', 'Your comment has been posted.');
}
refetch();
if (replyPostedHandler) {
replyPostedHandler();
}
})
.catch((err) => console.error(err));
this.setState({body: ''});
+3 -3
View File
@@ -3,10 +3,10 @@ import CommentBox from '../coral-plugin-commentbox/CommentBox';
const name = 'coral-plugin-replies';
const ReplyBox = ({styles, postItem, assetId, authorId, addNotification, parentId, refetch}) => (
const ReplyBox = ({styles, postItem, assetId, authorId, addNotification, parentId, replyPostedHandler}) => (
<div className={`${name}-textarea`} style={styles && styles.container}>
<CommentBox
refetch={refetch}
replyPostedHandler={replyPostedHandler}
parentId={parentId}
addNotification={addNotification}
authorId={authorId}
@@ -17,7 +17,7 @@ const ReplyBox = ({styles, postItem, assetId, authorId, addNotification, parentI
);
ReplyBox.propTypes = {
refetch: PropTypes.func.isRequired,
replyPostedHandler: PropTypes.func,
parentId: PropTypes.string,
addNotification: PropTypes.func.isRequired,
authorId: PropTypes.string.isRequired,