update comments tree after editing comment

This commit is contained in:
igoradamenko
2018-05-18 19:25:57 +03:00
parent a34122d437
commit c300d57730
2 changed files with 11 additions and 4 deletions
+9 -4
View File
@@ -30,7 +30,6 @@ export default class Root extends Component {
isLoaded: false,
isCommentsListLoading: false,
user: {},
replyingCommentId: null,
sort,
};
@@ -46,7 +45,6 @@ export default class Root extends Component {
componentWillMount() {
store.onUpdate('comments', comments => this.setState({ comments }));
store.onUpdate('replyingCommentId', id => this.setState({ replyingCommentId: id }));
}
componentDidMount() {
@@ -166,11 +164,17 @@ export default class Root extends Component {
api.getComment({ id: data.id }).then(comment => {
store.replaceComment(comment);
this.setState({ comments: store.get('comments') });
store.set('replyingCommentId', null);
});
}
render({}, { config = {}, comments = [], user, sort, isLoaded, isBlockedVisible, isCommentsListLoading, bannedUsers, replyingCommentId }) {
editComment(data) {
api.getComment({ id: data.id }).then(comment => {
store.replaceComment(comment);
this.setState({ comments: store.get('comments') });
});
}
render({}, { config = {}, comments = [], user, sort, isLoaded, isBlockedVisible, isCommentsListLoading, bannedUsers }) {
if (!isLoaded) {
return (
<div id={NODE_ID}>
@@ -238,6 +242,7 @@ export default class Root extends Component {
mods={{ level: 0 }}
data={thread}
onReply={this.addComment}
onEdit={this.editComment}
/>
))
}
+2
View File
@@ -31,6 +31,7 @@ export default class Thread extends Component {
data={comment}
mods={{ level: mods.level, collapsed, collapsible: !!replies.length }}
onReply={props.onReply}
onEdit={props.onEdit}
onCollapseToggle={this.onCollapseToggle}
/>
@@ -40,6 +41,7 @@ export default class Thread extends Component {
data={thread}
mods={{ level: mods.level < 5 ? mods.level + 1 : mods.level }}
onReply={props.onReply}
onEdit={props.onEdit}
/>
))
}