GH-4907 Move Client.updatePost call into an action (#5045)
* move Client.updatePost into an action Client.updatePost where called from components so they needed to be moved inside action and call that action from component instead fixes #4907 * move loadPost in updatePost callback * Add loadPosts call in updatePost action * Lint: remove trailing spaces
Этот коммит содержится в:
коммит произвёл
enahum
родитель
6c814c72ec
Коммит
e69809dce3
@@ -363,6 +363,21 @@ export function createPost(post, doLoadPost, success, error) {
|
||||
);
|
||||
}
|
||||
|
||||
export function updatePost(post, success) {
|
||||
Client.updatePost(
|
||||
post,
|
||||
() => {
|
||||
loadPosts(post.channel_id);
|
||||
|
||||
if (success) {
|
||||
success();
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
AsyncClient.dispatchError(err, 'updatePost');
|
||||
});
|
||||
}
|
||||
|
||||
export function removePostFromStore(post) {
|
||||
PostStore.removePost(post);
|
||||
PostStore.emitChange();
|
||||
|
||||
@@ -9,11 +9,9 @@ import MessageHistoryStore from 'stores/message_history_store.jsx';
|
||||
import PreferenceStore from 'stores/preference_store.jsx';
|
||||
|
||||
import * as GlobalActions from 'actions/global_actions.jsx';
|
||||
import {loadPosts} from 'actions/post_actions.jsx';
|
||||
import {updatePost} from 'actions/post_actions.jsx';
|
||||
|
||||
import Client from 'client/web_client.jsx';
|
||||
import * as UserAgent from 'utils/user_agent.jsx';
|
||||
import * as AsyncClient from 'utils/async_client.jsx';
|
||||
import * as Utils from 'utils/utils.jsx';
|
||||
import Constants from 'utils/constants.jsx';
|
||||
const KeyCodes = Constants.KeyCodes;
|
||||
@@ -91,16 +89,11 @@ export default class EditPostModal extends React.Component {
|
||||
return;
|
||||
}
|
||||
|
||||
Client.updatePost(
|
||||
updatePost(
|
||||
updatedPost,
|
||||
() => {
|
||||
loadPosts(updatedPost.channel_id);
|
||||
window.scrollTo(0, 0);
|
||||
},
|
||||
(err) => {
|
||||
AsyncClient.dispatchError(err, 'updatePost');
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$('#edit_post').modal('hide');
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user