itizawa 6 лет назад
Родитель
Сommit
34a3be9e14
1 измененных файлов с 18 добавлено и 19 удалено
  1. 18 19
      src/client/js/components/PageComment/CommentEditor.jsx

+ 18 - 19
src/client/js/components/PageComment/CommentEditor.jsx

@@ -91,33 +91,32 @@ class CommentEditor extends React.Component {
   /**
    * Post comment with CommentContainer and update state
    */
-  postHandler(event) {
+  async postHandler(event) {
     if (event != null) {
       event.preventDefault();
     }
 
     if (this.props.currentCommentId != null) {
-      this.props.commentContainer.putComment(
+      await this.props.commentContainer.putComment(
         this.state.comment,
         this.state.isMarkdown,
         this.props.currentCommentId,
-      )
-        .then((res) => {
-          this.setState({
-            comment: '',
-            isMarkdown: true,
-            html: '',
-            key: 1,
-            errorMessage: undefined,
-          });
-          // reset value
-          this.editor.setValue('');
-          this.toggleEditor();
-        })
-        .catch((err) => {
-          const errorMessage = err.message || 'An unknown error occured when posting comment';
-          this.setState({ errorMessage });
-        });
+      ).catch((err) => {
+        const errorMessage = err.message || 'An unknown error occured when posting comment';
+        this.setState({ errorMessage });
+      });
+
+      this.setState({
+        comment: '',
+        isMarkdown: true,
+        html: '',
+        key: 1,
+        errorMessage: undefined,
+      });
+      // reset value
+      this.editor.setValue('');
+      this.toggleEditor();
+
     }
     else {
       this.props.commentContainer.postComment(