From b757f11b8c435a34b1947da7d44bb3d9c1bcd0df Mon Sep 17 00:00:00 2001 From: wil Date: Tue, 20 Feb 2024 17:47:44 -0500 Subject: [PATCH] turned lazylist into pagination, just need to fix 1 bug more --- .../SelectModalWeightsTabs/tabAllWeights.tsx | 23 ++++++++++++------- .../tabBookmarkedWeights.tsx | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/fakeyou.com/src/components/common/SelectModalWeightsTabs/tabAllWeights.tsx b/packages/fakeyou.com/src/components/common/SelectModalWeightsTabs/tabAllWeights.tsx index 7cb050a77f..395e71f2c8 100644 --- a/packages/fakeyou.com/src/components/common/SelectModalWeightsTabs/tabAllWeights.tsx +++ b/packages/fakeyou.com/src/components/common/SelectModalWeightsTabs/tabAllWeights.tsx @@ -31,7 +31,13 @@ export default function WeightsTabsContent({ const bookmarks = useBookmarks(); const ratings = useRatings(); const [list, listSet] = useState([]); - const [pageCount, setPageCount] = useState(0); + const [pages, setPages] = useState<{ + currPageWeights: any[], + lookup: string[] + }>({ + currPageWeights: [], + lookup: [] + }); const weights = useLazyLists({ addQueries: { @@ -40,9 +46,11 @@ export default function WeightsTabsContent({ }, fetcher: ListWeights, onSuccess: (res)=>{ - setPageCount((curr)=>{ - if (curr==0) return res.pagination.maybe_next ? 2 : 0 - else return curr+res.pagination.maybe_next ? 1 : 0 + setPages((curr)=>{ + return{ + currPageWeights: [...res.results], + lookup: [...curr.lookup, res.pagination.maybe_next] + } }) }, list, @@ -53,13 +61,12 @@ export default function WeightsTabsContent({ const handlePageClick = (selectedItem: { selected: number }) => { - console.log("PAGECLICK") weights.getMore(); }; const paginationProps = { onPageChange: handlePageClick, - pageCount: pageCount, + pageCount: pages.lookup.length+1, currentPage: 0, }; if (weights.isLoading){ @@ -84,9 +91,9 @@ export default function WeightsTabsContent({ console.log("Layout complete!")} + // onLayoutComplete={() => console.log("Layout complete!")} > - {weights.list.map((data: any, key: number) => { + {pages.currPageWeights.map((data: any, key: number) => { let props = { data, ratings, diff --git a/packages/fakeyou.com/src/components/common/SelectModalWeightsTabs/tabBookmarkedWeights.tsx b/packages/fakeyou.com/src/components/common/SelectModalWeightsTabs/tabBookmarkedWeights.tsx index 5ab6b2852e..566ff32fc7 100644 --- a/packages/fakeyou.com/src/components/common/SelectModalWeightsTabs/tabBookmarkedWeights.tsx +++ b/packages/fakeyou.com/src/components/common/SelectModalWeightsTabs/tabBookmarkedWeights.tsx @@ -1,6 +1,6 @@ import React, {useRef, useState} from 'react'; import { - useBookmarks, + // useBookmarks, useListContent, useRatings, useSession