|
@@ -91,33 +91,32 @@ class CommentEditor extends React.Component {
|
|
|
/**
|
|
/**
|
|
|
* Post comment with CommentContainer and update state
|
|
* Post comment with CommentContainer and update state
|
|
|
*/
|
|
*/
|
|
|
- postHandler(event) {
|
|
|
|
|
|
|
+ async postHandler(event) {
|
|
|
if (event != null) {
|
|
if (event != null) {
|
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (this.props.currentCommentId != null) {
|
|
if (this.props.currentCommentId != null) {
|
|
|
- this.props.commentContainer.putComment(
|
|
|
|
|
|
|
+ await this.props.commentContainer.putComment(
|
|
|
this.state.comment,
|
|
this.state.comment,
|
|
|
this.state.isMarkdown,
|
|
this.state.isMarkdown,
|
|
|
this.props.currentCommentId,
|
|
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 {
|
|
else {
|
|
|
this.props.commentContainer.postComment(
|
|
this.props.commentContainer.postComment(
|