diff options
author | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2017-01-20 03:03:47 +0100 |
---|---|---|
committer | enahum <nahumhbl@gmail.com> | 2017-01-19 23:03:47 -0300 |
commit | 576c662f27d237e1f173d331aade6ab697911395 (patch) | |
tree | f0fd0a537eaa8534dd91edb6afa69da2ccb7322e /webapp/actions/post_actions.jsx | |
parent | 48e1fa8aa0ae3234d826d16eaff39cb373bc7d3d (diff) | |
download | chat-576c662f27d237e1f173d331aade6ab697911395.tar.gz chat-576c662f27d237e1f173d331aade6ab697911395.tar.bz2 chat-576c662f27d237e1f173d331aade6ab697911395.zip |
Move instances of Client.deletePost() in components to an action (#5129)
Diffstat (limited to 'webapp/actions/post_actions.jsx')
-rw-r--r-- | webapp/actions/post_actions.jsx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/webapp/actions/post_actions.jsx b/webapp/actions/post_actions.jsx index 4d472db45..7179b6365 100644 --- a/webapp/actions/post_actions.jsx +++ b/webapp/actions/post_actions.jsx @@ -384,3 +384,30 @@ export function removePostFromStore(post) { PostStore.removePost(post); PostStore.emitChange(); } + +export function deletePost(channelId, post, success, error) { + Client.deletePost( + channelId, + post.id, + () => { + removePostFromStore(post); + if (post.id === PostStore.getSelectedPostId()) { + AppDispatcher.handleServerAction({ + type: ActionTypes.RECEIVED_POST_SELECTED, + postId: null + }); + } + + if (success) { + success(); + } + }, + (err) => { + AsyncClient.dispatchError(err, 'deletePost'); + + if (error) { + error(err); + } + } + ); +} |