mirror of
https://github.com/wassname/talk.git
synced 2026-07-06 05:17:19 +08:00
close reply box when comment is posted
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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,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,
|
||||
|
||||
Reference in New Issue
Block a user