mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Simplify and improve pagination
This commit is contained in:
@ -16,16 +16,7 @@ export interface Props {
|
||||
const TimelineFooter: React.FC<Props> = ({ queryKey, disableInfinity }) => {
|
||||
const { hasNextPage } = useTimelineQuery({
|
||||
...queryKey[1],
|
||||
options: {
|
||||
enabled: !disableInfinity,
|
||||
notifyOnChangeProps: ['hasNextPage'],
|
||||
getNextPageParam: lastPage =>
|
||||
lastPage?.links?.next && {
|
||||
...(lastPage.links.next.isOffset
|
||||
? { offset: lastPage.links.next.id }
|
||||
: { max_id: lastPage.links.next.id })
|
||||
}
|
||||
}
|
||||
options: { enabled: !disableInfinity, notifyOnChangeProps: ['hasNextPage'] }
|
||||
})
|
||||
|
||||
const { colors } = useTheme()
|
||||
|
@ -148,11 +148,7 @@ const TimelineRefresh: React.FC<Props> = ({
|
||||
|
||||
await queryFunctionTimeline({
|
||||
queryKey,
|
||||
pageParam: firstPage?.links?.prev && {
|
||||
...(firstPage.links.prev.isOffset
|
||||
? { offset: firstPage.links.prev.id }
|
||||
: { min_id: firstPage.links.prev.id })
|
||||
},
|
||||
pageParam: firstPage?.links?.prev,
|
||||
meta: {}
|
||||
})
|
||||
.then(res => {
|
||||
|
@ -52,13 +52,7 @@ const Timeline: React.FC<Props> = ({
|
||||
notifyOnChangeProps: Platform.select({
|
||||
ios: ['dataUpdatedAt', 'isFetching'],
|
||||
android: ['dataUpdatedAt', 'isFetching', 'isLoading']
|
||||
}),
|
||||
getNextPageParam: lastPage =>
|
||||
lastPage?.links?.next && {
|
||||
...(lastPage.links.next.isOffset
|
||||
? { offset: lastPage.links.next.id }
|
||||
: { max_id: lastPage.links.next.id })
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user