Fixed issue with loading status context/comments in feature

• Fixed:
- issue with loading status context/comments in feature
This commit is contained in:
mgabdev 2020-07-21 23:44:35 -05:00
parent 92c4fa3fda
commit ae5d892221

View File

@ -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'))
}
}