summaryrefslogtreecommitdiffstats
path: root/webapp/components/create_comment.jsx
diff options
context:
space:
mode:
authorCarlos Tadeu Panato Junior <ctadeu@gmail.com>2016-12-05 18:59:12 +0100
committerHarrison Healey <harrisonmhealey@gmail.com>2016-12-05 12:59:12 -0500
commitf27aca4b73119078f82cb86ddf6cae3ec5ccdf68 (patch)
tree8045ea8d961716169823de15adc616f5b9d1db70 /webapp/components/create_comment.jsx
parentb9b986b7418472812a0391c2e83344553a15b4d9 (diff)
downloadchat-f27aca4b73119078f82cb86ddf6cae3ec5ccdf68.tar.gz
chat-f27aca4b73119078f82cb86ddf6cae3ec5ccdf68.tar.bz2
chat-f27aca4b73119078f82cb86ddf6cae3ec5ccdf68.zip
Move instances of Client.createPost() in components to an action (#4639)
* Move instances of Client.createPost() in components to an action * update per review, waiting for more review and see if this is the right way * update per code review * update code * remove comment per request
Diffstat (limited to 'webapp/components/create_comment.jsx')
-rw-r--r--webapp/components/create_comment.jsx31
1 files changed, 17 insertions, 14 deletions
diff --git a/webapp/components/create_comment.jsx b/webapp/components/create_comment.jsx
index e8378da2c..543aef202 100644
--- a/webapp/components/create_comment.jsx
+++ b/webapp/components/create_comment.jsx
@@ -4,7 +4,6 @@
import $ from 'jquery';
import ReactDOM from 'react-dom';
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
-import Client from 'client/web_client.jsx';
import EmojiStore from 'stores/emoji_store.jsx';
import UserStore from 'stores/user_store.jsx';
import PostDeletedModal from './post_deleted_modal.jsx';
@@ -163,24 +162,16 @@ export default class CreateComment extends React.Component {
post.create_at = time;
GlobalActions.emitUserCommentedEvent(post);
- Client.createPost(
- post,
- (data) => {
- PostStore.removePendingPost(post.channel_id, post.pending_post_id);
-
- AppDispatcher.handleServerAction({
- type: ActionTypes.RECEIVED_POST,
- post: data
- });
+
+ PostActions.createPost(post, false,
+ () => {
+ // DO nothing.
},
(err) => {
if (err.id === 'api.post.create_post.root_id.app_error') {
this.showPostDeletedModal();
-
- PostStore.removePendingPost(post.channel_id, post.pending_post_id);
} else {
- post.state = Constants.POST_FAILED;
- PostStore.updatePendingPost(post);
+ this.forceUpdate();
}
this.setState({
@@ -188,6 +179,18 @@ export default class CreateComment extends React.Component {
});
}
);
+
+ this.setState({
+ message: '',
+ submitting: false,
+ postError: null,
+ fileInfos: [],
+ serverError: null
+ });
+
+ const fasterThanHumanWillClick = 150;
+ const forceFocus = (Date.now() - this.state.lastBlurAt < fasterThanHumanWillClick);
+ this.focusTextbox(forceFocus);
}
handleSubmitReaction(isReaction) {