Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
PLT-7237 Remove failed post if commenting on deleted parent post (#216)
Browse files Browse the repository at this point in the history
* Remove failed post if commenting on deleted parent post

* Dispatch post failures to request store
  • Loading branch information
jwilander authored and hmhealey committed Aug 28, 2020
1 parent f5d618b commit 55fb9ec
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions packages/mattermost-redux/src/actions/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,28 @@ export function createPost(post, files = []) {
},
maxRetry: 0,
offlineRollback: true,
rollback: () => {
rollback: (success, error) => {
const data = {
...newPost,
id: pendingPostId,
failed: true
};

dispatch({
type: PostTypes.RECEIVED_POST,
data
});
const actions = [
{type: PostTypes.CREATE_POST_FAILURE, error}
];

// If the failure was because the root post was deleted, remove the post
if (error.server_error_id === 'api.post.create_post.root_id.app_error') {
removePost(data)(dispatch, getState);
} else {
actions.push({
type: PostTypes.RECEIVED_POST,
data
});
}

dispatch(batchActions(actions));
}
}
}
Expand Down

0 comments on commit 55fb9ec

Please sign in to comment.