Skip to content

Commit

Permalink
fix(masterbots.ai): infinite scroll issue on bot view (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
TopETH authored May 7, 2024
1 parent 2d9dde0 commit 4b739c2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/masterbots.ai/components/shared/thread-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function ThreadList({
queryFn: async props => {
return getBrowseThreads({
...filter,
offset: props.pageParam * limit,
offset: (props.pageParam - 1) * limit,
limit,
query
})
Expand All @@ -58,7 +58,11 @@ export function ThreadList({
useEffect(() => {
// only load add observer if we get at least iquals to limit on initialThreads
// TODO: get thread count from server db query
if (!loadMoreRef.current || initialThreads.length < limit) return
if (
!loadMoreRef.current ||
data.pages[data.pages.length - 1].length < limit
)
return
const observer = new IntersectionObserver(([entry]) => {
if (entry.isIntersecting && !isFetchingNextPage) {
setTimeout(() => {
Expand Down

0 comments on commit 4b739c2

Please sign in to comment.