Can go back to old items list now
This commit is contained in:
@ -675,25 +675,18 @@ export function LibraryContainer(props: LibraryContainerProps): JSX.Element {
|
||||
activeCardId ? [...ACTIVE_ACTIONS, ...UNACTIVE_ACTIONS] : UNACTIVE_ACTIONS,
|
||||
[activeCardId, activeItem]
|
||||
)
|
||||
// useFetchMore(
|
||||
// () => {
|
||||
// if (!isFetching && !isLoading && hasNextPage) {
|
||||
// fetchNextPage()
|
||||
// }
|
||||
// },
|
||||
// () => {
|
||||
// if (!isFetching && !isLoading && hasPreviousPage) {
|
||||
// fetchPreviousPage()
|
||||
// }
|
||||
// }
|
||||
// )
|
||||
|
||||
// console.log(
|
||||
// 'isFetching && !isLoading, isFetchingNextPage',
|
||||
// isFetching,
|
||||
// isLoading,
|
||||
// isFetchingNextPage
|
||||
// )
|
||||
useFetchMore(
|
||||
() => {
|
||||
if (!isFetching && !isLoading && hasNextPage) {
|
||||
fetchNextPage()
|
||||
}
|
||||
},
|
||||
() => {
|
||||
if (!isFetching && !isLoading && hasPreviousPage) {
|
||||
fetchPreviousPage()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const setIsChecked = useCallback(
|
||||
(itemId: string, set: boolean) => {
|
||||
@ -810,32 +803,32 @@ export function LibraryContainer(props: LibraryContainerProps): JSX.Element {
|
||||
[itemsPages, multiSelectMode, checkedItems]
|
||||
)
|
||||
|
||||
return (
|
||||
<InfiniteScroll
|
||||
dataLength={libraryItems.length}
|
||||
next={fetchNextPage}
|
||||
hasMore={hasNextPage}
|
||||
loader={<h4>Loading...</h4>}
|
||||
endMessage={
|
||||
<p style={{ textAlign: 'center' }}>
|
||||
<b>Yay! You have seen it all</b>
|
||||
</p>
|
||||
}
|
||||
>
|
||||
{libraryItems.map((item) => {
|
||||
return (
|
||||
<Box
|
||||
key={item.node.id}
|
||||
onClick={() => {
|
||||
router.push(`/${viewerData?.profile.username}/${item.node.slug}`)
|
||||
}}
|
||||
>
|
||||
{item.cursor}: {item.node.title}
|
||||
</Box>
|
||||
)
|
||||
})}
|
||||
</InfiniteScroll>
|
||||
)
|
||||
// return (
|
||||
// <InfiniteScroll
|
||||
// dataLength={libraryItems.length}
|
||||
// next={fetchNextPage}
|
||||
// hasMore={hasNextPage}
|
||||
// loader={<h4>Loading...</h4>}
|
||||
// endMessage={
|
||||
// <p style={{ textAlign: 'center' }}>
|
||||
// <b>Yay! You have seen it all</b>
|
||||
// </p>
|
||||
// }
|
||||
// >
|
||||
// {libraryItems.map((item) => {
|
||||
// return (
|
||||
// <Box
|
||||
// key={item.node.id}
|
||||
// onClick={() => {
|
||||
// router.push(`/${viewerData?.profile.username}/${item.node.slug}`)
|
||||
// }}
|
||||
// >
|
||||
// {item.cursor}: {item.node.title}
|
||||
// </Box>
|
||||
// )
|
||||
// })}
|
||||
// </InfiniteScroll>
|
||||
// )
|
||||
|
||||
return (
|
||||
<HomeFeedGrid
|
||||
|
||||
@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from 'react'
|
||||
|
||||
export const useFetchMore = (
|
||||
fetchNextPage: () => void,
|
||||
fetchPreviousPage: () => void,
|
||||
// fetchPreviousPage: () => void,
|
||||
delay = 500
|
||||
): void => {
|
||||
const [first, setFirst] = useState(true)
|
||||
@ -21,10 +21,10 @@ export const useFetchMore = (
|
||||
scrollTop + clientHeight >= scrollHeight - scrollHeight / 3
|
||||
) {
|
||||
fetchNextPage()
|
||||
} else if (direction == 'up' && scrollTop < 300) {
|
||||
} /* else if (direction == 'up' && scrollTop < 300) {
|
||||
console.log('calling fetchPrevious: ', scrollTop)
|
||||
fetchPreviousPage()
|
||||
}
|
||||
} */
|
||||
|
||||
throttleTimeout.current = undefined
|
||||
}
|
||||
@ -45,5 +45,5 @@ export const useFetchMore = (
|
||||
return () => {
|
||||
window.removeEventListener('scroll', handleScroll)
|
||||
}
|
||||
}, [fetchNextPage, fetchPreviousPage, delay, first, setFirst])
|
||||
}, [fetchNextPage, /* fetchPreviousPage, */ delay, first, setFirst])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user