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:
@@ -230,8 +230,9 @@ export const expandHomeTimeline = ({ maxId } = {}, done = noop) => {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export const expandExploreTimeline = ({ maxId, sortBy } = {}, done = noop) => {
|
||||
export const expandExploreTimeline = ({ maxId, sortBy, page } = {}, done = noop) => {
|
||||
return expandTimeline('explore', '/api/v1/timelines/explore', {
|
||||
page,
|
||||
max_id: maxId,
|
||||
sort_by: sortBy,
|
||||
}, done)
|
||||
@@ -303,10 +304,11 @@ export const expandListTimeline = (id, { maxId } = {}, done = noop) => {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export const expandGroupTimeline = (id, { sortBy, maxId, onlyMedia } = {}, done = noop) => {
|
||||
export const expandGroupTimeline = (id, { sortBy, maxId, onlyMedia, page } = {}, done = noop) => {
|
||||
if (!id) return
|
||||
|
||||
return expandTimeline(`group:${id}`, `/api/v1/timelines/group/${id}`, {
|
||||
page,
|
||||
sort_by: sortBy,
|
||||
max_id: maxId,
|
||||
only_media: onlyMedia
|
||||
@@ -323,8 +325,9 @@ export const expandGroupFeaturedTimeline = (groupId, done = noop) => {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export const expandGroupCollectionTimeline = (collectionType, { sortBy, maxId } = {}, done = noop) => {
|
||||
export const expandGroupCollectionTimeline = (collectionType, { sortBy, maxId, page } = {}, done = noop) => {
|
||||
return expandTimeline(`group_collection:${collectionType}`, `/api/v1/timelines/group_collection/${collectionType}`, {
|
||||
page,
|
||||
sort_by: sortBy,
|
||||
max_id: maxId,
|
||||
}, done)
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -24,9 +24,9 @@ import GroupsCollection from './groups_collection'
|
||||
class GroupCollectionTimeline 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() {
|
||||
@@ -61,17 +61,14 @@ 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 { page } = this.state
|
||||
|
||||
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.onExpandGroupCollectionTimeline(collectionType, options)
|
||||
}
|
||||
@@ -82,7 +79,7 @@ class GroupCollectionTimeline extends React.PureComponent {
|
||||
intl,
|
||||
hasNoGroupMembers,
|
||||
} = this.props
|
||||
const { loadCount } = this.state
|
||||
const { page } = this.state
|
||||
|
||||
const emptyMessage = !!me && collectionType === 'member' && hasNoGroupMembers ? (
|
||||
<div className={[_s.d, _s.w100PC]}>
|
||||
@@ -93,7 +90,7 @@ class GroupCollectionTimeline extends React.PureComponent {
|
||||
</div>
|
||||
) : intl.formatMessage(messages.empty)
|
||||
|
||||
const canLoadMore = loadCount < 2 && !me || !!me
|
||||
const canLoadMore = page < 2 && !me || !!me
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
|
||||
@@ -25,9 +25,9 @@ import GroupSortBlock from '../components/group_sort_block'
|
||||
class GroupTimeline extends ImmutablePureComponent {
|
||||
|
||||
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() {
|
||||
@@ -72,17 +72,19 @@ 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 { page } = this.state
|
||||
|
||||
const newPage = !!maxId ? this.state.page + 1 : 1
|
||||
if (!!maxId && !me && page >= 2) return false
|
||||
this.setState({ page: newPage })
|
||||
|
||||
const sortBy = getSortBy(sortByValue, sortByTopValue)
|
||||
this.props.onExpandGroupTimeline(groupId, { sortBy, maxId, onlyMedia })
|
||||
this.props.onExpandGroupTimeline(groupId, {
|
||||
sortBy,
|
||||
maxId,
|
||||
onlyMedia,
|
||||
page: newPage,
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -92,7 +94,7 @@ class GroupTimeline extends ImmutablePureComponent {
|
||||
intl,
|
||||
groupPinnedStatusIds,
|
||||
} = this.props
|
||||
const { loadCount } = this.state
|
||||
const { page } = this.state
|
||||
|
||||
if (typeof group === 'undefined') {
|
||||
return <ColumnIndicator type='loading' />
|
||||
@@ -100,7 +102,7 @@ class GroupTimeline extends ImmutablePureComponent {
|
||||
return <ColumnIndicator type='missing' />
|
||||
}
|
||||
|
||||
const canLoadMore = loadCount < 2 && !me || !!me
|
||||
const canLoadMore = page < 2 && !me || !!me
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
|
||||
Reference in New Issue
Block a user