RN-616 Added a fallback to prevent posts from being stuck as pending forever (#1381)
This commit is contained in:
parent
e43c7d8cbf
commit
bc42db3e87
1 changed files with 13 additions and 2 deletions
|
|
@ -12,17 +12,28 @@ import {isEdited, isPostEphemeral, isSystemMessage} from 'mattermost-redux/utils
|
|||
|
||||
import PostBody from './post_body';
|
||||
|
||||
const POST_TIMEOUT = 20000;
|
||||
|
||||
function mapStateToProps(state, ownProps) {
|
||||
const post = getPost(state, ownProps.postId);
|
||||
|
||||
let isFailed = post.failed;
|
||||
let isPending = post.id === post.pending_post_id;
|
||||
if (isPending && Date.now() - post.create_at > POST_TIMEOUT) {
|
||||
// Something has prevented the post from being set to failed, so it's safe to assume
|
||||
// that it has actually failed by this point
|
||||
isFailed = true;
|
||||
isPending = false;
|
||||
}
|
||||
|
||||
return {
|
||||
postProps: post.props || {},
|
||||
fileIds: post.file_ids,
|
||||
hasBeenDeleted: post.state === Posts.POST_DELETED,
|
||||
hasBeenEdited: isEdited(post),
|
||||
hasReactions: post.has_reactions,
|
||||
isFailed: post.failed,
|
||||
isPending: post.id === post.pending_post_id,
|
||||
isFailed,
|
||||
isPending,
|
||||
isPostEphemeral: isPostEphemeral(post),
|
||||
isSystemMessage: isSystemMessage(post),
|
||||
message: post.message,
|
||||
|
|
|
|||
Loading…
Reference in a new issue