From bc42db3e87e84dfb3fcc28f2db579cff52e4effc Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Fri, 26 Jan 2018 12:09:08 -0500 Subject: [PATCH] RN-616 Added a fallback to prevent posts from being stuck as pending forever (#1381) --- app/components/post_body/index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/components/post_body/index.js b/app/components/post_body/index.js index bbd2645cb..21fb8a3fb 100644 --- a/app/components/post_body/index.js +++ b/app/components/post_body/index.js @@ -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,