summaryrefslogtreecommitdiffstats
path: root/webapp/actions/post_actions.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/actions/post_actions.jsx')
-rw-r--r--webapp/actions/post_actions.jsx27
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);
+ }
+ }
+ );
+}