From a6d1aaae3d7dd993efb89a2201a757e0620dd302 Mon Sep 17 00:00:00 2001 From: J1min Date: Sun, 5 Mar 2023 20:49:17 +0900 Subject: [PATCH 01/17] =?UTF-8?q?Feat:=20hasNextPage=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/main/MainPortfolioList.tsx | 10 ++++++---- components/portfolio/PortfolioList.tsx | 8 ++++---- models/portfolio/index.ts | 6 +++--- pages/index.tsx | 4 ++-- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/components/main/MainPortfolioList.tsx b/components/main/MainPortfolioList.tsx index df2ce5ef..ff1efd0b 100644 --- a/components/main/MainPortfolioList.tsx +++ b/components/main/MainPortfolioList.tsx @@ -8,12 +8,12 @@ import Loading from "../common/Loading"; export default function MainPortfolioList({ pages, - hasNextPage, + customHasNextPage, fetchNextPage, isFetchingNextPage, }: { pages: PortfolioList[] | { list: never[] }[]; - hasNextPage: boolean; + customHasNextPage: boolean; fetchNextPage: FetchNextPageType; isFetchingNextPage: boolean; }) { @@ -21,8 +21,10 @@ export default function MainPortfolioList({ const [ref, inView] = useInView(); useEffect(() => { - if (inView && hasNextPage) fetchNextPage(); - }, [inView, fetchNextPage, hasNextPage]); + if (inView && customHasNextPage) { + fetchNextPage(); + } + }, [inView, fetchNextPage, customHasNextPage]); return ( <> diff --git a/components/portfolio/PortfolioList.tsx b/components/portfolio/PortfolioList.tsx index 25d20b19..31f634bb 100644 --- a/components/portfolio/PortfolioList.tsx +++ b/components/portfolio/PortfolioList.tsx @@ -24,14 +24,14 @@ export default function PortfolioList({ return filter; }; - const { pages, fetchNextPage, hasNextPage, isFetchingNextPage } = + const { pages, fetchNextPage, customHasNextPage, isFetchingNextPage } = usePortfolioList({ size: 12 }, { search: keyword, ...filterSortType() }); const { ref, inView } = useInView(); useEffect(() => { - if (inView && hasNextPage) fetchNextPage(); - }, [inView, hasNextPage, fetchNextPage]); + if (inView && customHasNextPage) fetchNextPage(); + }, [inView, customHasNextPage, fetchNextPage]); return (
@@ -49,7 +49,7 @@ export default function PortfolioList({

검색결과가 없습니다.

)}
- {isFetchingNextPage && hasNextPage && ( + {isFetchingNextPage && customHasNextPage && ( )}
diff --git a/models/portfolio/index.ts b/models/portfolio/index.ts index a8c9cb9b..dd1d72b8 100644 --- a/models/portfolio/index.ts +++ b/models/portfolio/index.ts @@ -15,10 +15,10 @@ interface CommentList { } const usePortfolioList = (pagination: PaginationRequest, filter?: Filter) => { - const { data, isFetchingNextPage, fetchNextPage, hasNextPage } = + const { data, isFetchingNextPage, fetchNextPage } = useInfiniteQuery( [KEY.PORTFOLIO_LIST, filter], - ({ pageParam = 0 }) => + ({ pageParam = 1 }) => httpClient.portfolio .search({ pagination: { ...pagination, page: pageParam }, @@ -33,7 +33,7 @@ const usePortfolioList = (pagination: PaginationRequest, filter?: Filter) => { return { pages: data?.pages ?? [{ list: [] }], isFetchingNextPage, - hasNextPage, + customHasNextPage: !!data?.pages[Number(data.pages.length) - 1].list.length, fetchNextPage, }; }; diff --git a/pages/index.tsx b/pages/index.tsx index 00b48d9d..2dfa66b9 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -8,7 +8,7 @@ import { SortType } from "@/types/portfolio.interface"; export default function Home() { const [keyword, setKeyword] = useState("ALL"); - const { pages, isFetchingNextPage, fetchNextPage, hasNextPage } = + const { pages, isFetchingNextPage, fetchNextPage, customHasNextPage } = usePortfolioList( { size: 12 }, keyword !== "ALL" ? { sortType: keyword } : {}, @@ -19,7 +19,7 @@ export default function Home() { app={ From d8a6c4ff1b3731ccb41045d08ebd4738c580c37a Mon Sep 17 00:00:00 2001 From: J1min Date: Sun, 5 Mar 2023 20:54:27 +0900 Subject: [PATCH 02/17] =?UTF-8?q?Fix:=20PortfolioPlayer=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20=EA=B8=B8=EC=9D=B4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/app/PortfolioPlayer.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/app/PortfolioPlayer.tsx b/components/app/PortfolioPlayer.tsx index 796db657..3c2c8cfc 100644 --- a/components/app/PortfolioPlayer.tsx +++ b/components/app/PortfolioPlayer.tsx @@ -26,9 +26,9 @@ export default function PortfolioPlayer({