From ae5d892221bf5c9ac6af2423c00158eb5f0f0d30 Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Tue, 21 Jul 2020 23:44:35 -0500 Subject: [PATCH] Fixed issue with loading status context/comments in feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Fixed: - issue with loading status context/comments in feature --- app/javascript/gabsocial/features/status.js | 24 +++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/app/javascript/gabsocial/features/status.js b/app/javascript/gabsocial/features/status.js index 029a30d7..41ec973f 100644 --- a/app/javascript/gabsocial/features/status.js +++ b/app/javascript/gabsocial/features/status.js @@ -42,20 +42,30 @@ class Status extends ImmutablePureComponent { componentDidMount() { const statusId = this.props.id || this.props.params.statusId this.props.onFetchStatus(statusId) + + if (!!this.props.status) { + this.shouldFetchStatusParts(this.props.status) + } } componentDidUpdate(prevProps) { const { status } = this.props if (prevProps.status !== status && !!status) { - const isComment = !!status.get('in_reply_to_account_id') - const hasComments = status.get('replies_count') > 0 + this.shouldFetchStatusParts(status) + } + } - if (isComment) { - this.props.onFetchContext(status.get('id')) - } else if (!isComment && hasComments) { - this.props.onFetchComments(status.get('id')) - } + shouldFetchStatusParts = (status) => { + if (!status) return + + const isComment = !!status.get('in_reply_to_account_id') + const hasComments = status.get('replies_count') > 0 + + if (isComment) { + this.props.onFetchContext(status.get('id')) + } else if (!isComment && hasComments) { + this.props.onFetchComments(status.get('id')) } }