Added check for if no user, only load more twice

• Added:
- check for if no user, only load more twice on GroupCollectionTimeline, GroupTimeline
This commit is contained in:
mgabdev 2020-09-14 17:19:24 -05:00
parent 2933921d04
commit 4fd274348c
2 changed files with 25 additions and 3 deletions

View File

@ -92,19 +92,28 @@ class GroupCollectionTimeline extends React.PureComponent {
sortByValue,
sortByTopValue,
} = this.props
const { loadCount } = this.state
if (!!maxId && !me) {
this.setState({ loadCount: this.state.loadCount + 1 })
if (loadCount >= 2) return false
} else if (!maxId && loadCount !== 0) {
this.setState({ loadCount: 0 })
}
const sortBy = getSortBy(sortByValue, sortByTopValue)
const options = { sortBy, maxId }
this.props.onExpandGroupCollectionTimeline(collectionType, options)
}
render() {
const {
collectionType,
intl,
hasNoGroupMembers,
} = this.props
const { loadCount } = this.state
const emptyMessage = !!me && collectionType === 'member' && hasNoGroupMembers ? (
<div className={[_s.d, _s.w100PC]}>
@ -115,13 +124,15 @@ class GroupCollectionTimeline extends React.PureComponent {
</div>
) : intl.formatMessage(messages.empty)
const canLoadMore = loadCount < 2 && !me || !!me
return (
<React.Fragment>
<GroupSortBlock collectionType={collectionType} />
<StatusList
scrollKey={`group-collection-timeline-${collectionType}`}
timelineId={`group_collection:${collectionType}`}
onLoadMore={this.handleLoadMore}
onLoadMore={canLoadMore ? this.handleLoadMore : undefined}
emptyMessage={emptyMessage}
/>
</React.Fragment>

View File

@ -81,7 +81,15 @@ class GroupTimeline extends ImmutablePureComponent {
sortByTopValue,
onlyMedia,
} = this.props
const { loadCount } = this.state
if (!!maxId && !me) {
this.setState({ loadCount: this.state.loadCount + 1 })
if (loadCount >= 2) return false
} else if (!maxId && loadCount !== 0) {
this.setState({ loadCount: 0 })
}
const sortBy = getSortBy(sortByValue, sortByTopValue)
this.props.onExpandGroupTimeline(groupId, { sortBy, maxId, onlyMedia })
}
@ -93,6 +101,7 @@ class GroupTimeline extends ImmutablePureComponent {
intl,
groupPinnedStatusIds,
} = this.props
const { loadCount } = this.state
if (typeof group === 'undefined') {
return <ColumnIndicator type='loading' />
@ -100,14 +109,16 @@ class GroupTimeline extends ImmutablePureComponent {
return <ColumnIndicator type='missing' />
}
const canLoadMore = loadCount < 2 && !me || !!me
return (
<React.Fragment>
<GroupSortBlock />
<StatusList
scrollKey={`group-timeline-${groupId}`}
timelineId={`group:${groupId}`}
onLoadMore={this.handleLoadMore}
groupPinnedStatusIds={groupPinnedStatusIds}
onLoadMore={canLoadMore ? this.handleLoadMore : undefined}
emptyMessage={intl.formatMessage(messages.empty)}
/>
</React.Fragment>