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:
parent
2933921d04
commit
4fd274348c
@ -92,6 +92,14 @@ class GroupCollectionTimeline extends React.PureComponent {
|
|||||||
sortByValue,
|
sortByValue,
|
||||||
sortByTopValue,
|
sortByTopValue,
|
||||||
} = this.props
|
} = 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 sortBy = getSortBy(sortByValue, sortByTopValue)
|
||||||
const options = { sortBy, maxId }
|
const options = { sortBy, maxId }
|
||||||
@ -105,6 +113,7 @@ class GroupCollectionTimeline extends React.PureComponent {
|
|||||||
intl,
|
intl,
|
||||||
hasNoGroupMembers,
|
hasNoGroupMembers,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
const { loadCount } = this.state
|
||||||
|
|
||||||
const emptyMessage = !!me && collectionType === 'member' && hasNoGroupMembers ? (
|
const emptyMessage = !!me && collectionType === 'member' && hasNoGroupMembers ? (
|
||||||
<div className={[_s.d, _s.w100PC]}>
|
<div className={[_s.d, _s.w100PC]}>
|
||||||
@ -115,13 +124,15 @@ class GroupCollectionTimeline extends React.PureComponent {
|
|||||||
</div>
|
</div>
|
||||||
) : intl.formatMessage(messages.empty)
|
) : intl.formatMessage(messages.empty)
|
||||||
|
|
||||||
|
const canLoadMore = loadCount < 2 && !me || !!me
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<GroupSortBlock collectionType={collectionType} />
|
<GroupSortBlock collectionType={collectionType} />
|
||||||
<StatusList
|
<StatusList
|
||||||
scrollKey={`group-collection-timeline-${collectionType}`}
|
scrollKey={`group-collection-timeline-${collectionType}`}
|
||||||
timelineId={`group_collection:${collectionType}`}
|
timelineId={`group_collection:${collectionType}`}
|
||||||
onLoadMore={this.handleLoadMore}
|
onLoadMore={canLoadMore ? this.handleLoadMore : undefined}
|
||||||
emptyMessage={emptyMessage}
|
emptyMessage={emptyMessage}
|
||||||
/>
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
@ -81,6 +81,14 @@ class GroupTimeline extends ImmutablePureComponent {
|
|||||||
sortByTopValue,
|
sortByTopValue,
|
||||||
onlyMedia,
|
onlyMedia,
|
||||||
} = this.props
|
} = 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 sortBy = getSortBy(sortByValue, sortByTopValue)
|
||||||
this.props.onExpandGroupTimeline(groupId, { sortBy, maxId, onlyMedia })
|
this.props.onExpandGroupTimeline(groupId, { sortBy, maxId, onlyMedia })
|
||||||
@ -93,6 +101,7 @@ class GroupTimeline extends ImmutablePureComponent {
|
|||||||
intl,
|
intl,
|
||||||
groupPinnedStatusIds,
|
groupPinnedStatusIds,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
const { loadCount } = this.state
|
||||||
|
|
||||||
if (typeof group === 'undefined') {
|
if (typeof group === 'undefined') {
|
||||||
return <ColumnIndicator type='loading' />
|
return <ColumnIndicator type='loading' />
|
||||||
@ -100,14 +109,16 @@ class GroupTimeline extends ImmutablePureComponent {
|
|||||||
return <ColumnIndicator type='missing' />
|
return <ColumnIndicator type='missing' />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const canLoadMore = loadCount < 2 && !me || !!me
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<GroupSortBlock />
|
<GroupSortBlock />
|
||||||
<StatusList
|
<StatusList
|
||||||
scrollKey={`group-timeline-${groupId}`}
|
scrollKey={`group-timeline-${groupId}`}
|
||||||
timelineId={`group:${groupId}`}
|
timelineId={`group:${groupId}`}
|
||||||
onLoadMore={this.handleLoadMore}
|
|
||||||
groupPinnedStatusIds={groupPinnedStatusIds}
|
groupPinnedStatusIds={groupPinnedStatusIds}
|
||||||
|
onLoadMore={canLoadMore ? this.handleLoadMore : undefined}
|
||||||
emptyMessage={intl.formatMessage(messages.empty)}
|
emptyMessage={intl.formatMessage(messages.empty)}
|
||||||
/>
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user