Updated SortingQueryBuilder for ExploreTimeline, GroupCollectionTimeline, GroupTimeline

• Updated:
- SortingQueryBuilder for ExploreTimeline, GroupCollectionTimeline, GroupTimeline

• TODO
- Test on a lot of data to ensure no repeats
- Test reducers/timeline updates to appending and concating non status.id sorted results
This commit is contained in:
mgabdev
2020-12-24 13:34:14 -05:00
parent 7dd71a06ca
commit 620f50752f
8 changed files with 95 additions and 72 deletions

View File

@@ -23,9 +23,9 @@ import GroupSortBlock from '../components/group_sort_block'
class ExploreTimeline extends React.PureComponent {
state = {
//keep track of loads for if no user,
//only allow 2 loads before showing sign up msg
loadCount: 0,
//keep track of page loads for if no user,
//only allow 2 page loads before showing sign up msg
page: 1,
}
componentDidMount() {
@@ -55,26 +55,23 @@ class ExploreTimeline extends React.PureComponent {
sortByValue,
sortByTopValue,
} = this.props
const { loadCount } = this.state
const { page } = 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 newPage = !!maxId ? this.state.page + 1 : 1
if (!!maxId && !me && page >= 2) return false
this.setState({ page: newPage })
const sortBy = getSortBy(sortByValue, sortByTopValue)
const options = { sortBy, maxId }
const options = { sortBy, maxId, page: newPage }
this.props.onExpandExploreTimeline(options)
}
render() {
const { intl } = this.props
const { loadCount } = this.state
const { page } = this.state
const canLoadMore = loadCount < 2 && !me || !!me
const canLoadMore = page < 2 && !me || !!me
return (
<React.Fragment>