|
|
@@ -88,6 +88,19 @@ class CommentEditor extends React.Component {
|
|
|
this.props.commentButtonClickedHandler(targetId);
|
|
|
}
|
|
|
|
|
|
+ initializeEditor() {
|
|
|
+ this.setState({
|
|
|
+ comment: '',
|
|
|
+ isMarkdown: true,
|
|
|
+ html: '',
|
|
|
+ key: 1,
|
|
|
+ errorMessage: undefined,
|
|
|
+ });
|
|
|
+ // reset value
|
|
|
+ this.editor.setValue('');
|
|
|
+ this.toggleEditor();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Post comment with CommentContainer and update state
|
|
|
*/
|
|
|
@@ -97,37 +110,35 @@ class CommentEditor extends React.Component {
|
|
|
}
|
|
|
|
|
|
if (this.props.currentCommentId != null) {
|
|
|
- await this.props.commentContainer.putComment(
|
|
|
- this.state.comment,
|
|
|
- this.state.isMarkdown,
|
|
|
- this.props.currentCommentId,
|
|
|
- ).catch((err) => {
|
|
|
+ try {
|
|
|
+ await this.props.commentContainer.putComment(
|
|
|
+ this.state.comment,
|
|
|
+ this.state.isMarkdown,
|
|
|
+ this.props.currentCommentId,
|
|
|
+ );
|
|
|
+ this.initializeEditor();
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
const errorMessage = err.message || 'An unknown error occured when puting comment';
|
|
|
this.setState({ errorMessage });
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
- await this.props.commentContainer.postComment(
|
|
|
- this.state.comment,
|
|
|
- this.state.isMarkdown,
|
|
|
- this.props.replyTo,
|
|
|
- this.props.commentContainer.state.isSlackEnabled,
|
|
|
- this.props.commentContainer.state.slackChannels,
|
|
|
- ).catch((err) => {
|
|
|
+ try {
|
|
|
+ await this.props.commentContainer.postComment(
|
|
|
+ this.state.comment,
|
|
|
+ this.state.isMarkdown,
|
|
|
+ this.props.replyTo,
|
|
|
+ this.props.commentContainer.state.isSlackEnabled,
|
|
|
+ this.props.commentContainer.state.slackChannels,
|
|
|
+ );
|
|
|
+ this.initializeEditor();
|
|
|
+ }
|
|
|
+ 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();
|
|
|
}
|
|
|
|
|
|
uploadHandler(file) {
|