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
Этот коммит содержится в:
Carlos Tadeu Panato Junior
2016-12-05 18:59:12 +01:00
коммит произвёл Harrison Healey
родитель b9b986b741
Коммит f27aca4b73
4 изменённых файлов: 68 добавлений и 49 удалений

Просмотреть файл

@@ -11,7 +11,6 @@ import TutorialTip from './tutorial/tutorial_tip.jsx';
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import Client from 'client/web_client.jsx';
import * as Utils from 'utils/utils.jsx';
import * as UserAgent from 'utils/user_agent.jsx';
import * as ChannelActions from 'actions/channel_actions.jsx';
@@ -158,24 +157,16 @@ export default class CreatePost extends React.Component {
GlobalActions.emitUserPostedEvent(post);
Client.createPost(post,
(data) => {
PostStore.removePendingPost(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 should never actually happen since you can't reply from this textbox
this.showPostDeletedModal();
PostStore.removePendingPost(post.pending_post_id);
} else {
post.state = Constants.POST_FAILED;
PostStore.updatePendingPost(post);
this.forceUpdate();
}
this.setState({