From 1c14b1f52ccf3d4ee087d3b074cdf451d9ab3b40 Mon Sep 17 00:00:00 2001 From: judymoody59 Date: Mon, 21 Apr 2025 23:31:46 +0900 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20home=20=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=20=EB=AC=B4=ED=95=9C=EC=8A=A4=ED=81=AC=EB=A1=A4=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/home/home.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/app/home/home.js b/src/app/home/home.js index 6fc0bce..c40c3e2 100644 --- a/src/app/home/home.js +++ b/src/app/home/home.js @@ -169,6 +169,8 @@ export default function Home() { useEffect(() => {fetchProfile()}, [accessToken]); useEffect(() => {fetchTeams();}, [accessToken]); useEffect(() => { + if (cards.length === 0) return; + cards.forEach((team) => { if (!teamMembers[team.teamId]) { fetchTeamMembers(team.teamId); From 9fb38162a86cc077a78d2600eb029d9cd7340711 Mon Sep 17 00:00:00 2001 From: judymoody59 Date: Mon, 21 Apr 2025 23:40:00 +0900 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20home=20=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=20=EB=AC=B4=ED=95=9C=EC=8A=A4=ED=81=AC=EB=A1=A4=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=952?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/home/home.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/home/home.js b/src/app/home/home.js index c40c3e2..c0ede4d 100644 --- a/src/app/home/home.js +++ b/src/app/home/home.js @@ -56,7 +56,7 @@ export default function Home() { const fetchTeams = async () => { - if (isFetching || !hasMore) return; // 이미 요청 중이거나 더 이상 불러올 데이터 없으면 중단 + if (isFetching || !hasMore || (cards.length === 0 && lastTeamId !== null)) return; // 이미 요청 중이거나 더 이상 불러올 데이터 없으면 중단 setIsFetching(true); try { @@ -277,11 +277,11 @@ export default function Home() { ) : ( {isFetching ? ( - //로딩 중이면 카드 대신 스피너만 보여주기 -
- -
- ) : (<> + //로딩 중이면 카드 대신 스피너만 보여주기 +
+ +
+ ) : (<> {cards.map((team) => ( { window.location.href = `/team/${team.teamId}`; From 1a041c66b065f95720f76b506a1bf72a71455e7b Mon Sep 17 00:00:00 2001 From: judymoody59 Date: Mon, 21 Apr 2025 23:52:07 +0900 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20home=20=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=20=EB=AC=B4=ED=95=9C=EC=8A=A4=ED=81=AC=EB=A1=A4=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=953?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/home/home.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/app/home/home.js b/src/app/home/home.js index c0ede4d..f8e7957 100644 --- a/src/app/home/home.js +++ b/src/app/home/home.js @@ -56,7 +56,7 @@ export default function Home() { const fetchTeams = async () => { - if (isFetching || !hasMore || (cards.length === 0 && lastTeamId !== null)) return; // 이미 요청 중이거나 더 이상 불러올 데이터 없으면 중단 + if (isFetching || !hasMore ) return; // 이미 요청 중이거나 더 이상 불러올 데이터 없으면 중단 setIsFetching(true); try { @@ -79,25 +79,22 @@ export default function Home() { if (newContent.length === 0) { // 데이터가 비어 있으면 더 이상 불러올 게 없음 setHasMore(false); - } else { - // 기존 목록 + 새로 가져온 목록 + return; + } setCards((prev) => { const existingIds = new Set(prev.map((team) => team.teamId)); const uniqueNewContent = newContent.filter((team) => !existingIds.has(team.teamId)); return [...prev, ...uniqueNewContent]; - }); + }); // 마지막 아이템의 teamId를 nextLastId로 const nextLastId = newContent[newContent.length - 1].teamId; - setLastTeamId(nextLastId); - } + setLastTeamId(nextLastId); - // last === true 이면 더 이상 페이지 없음 if (isLastPage) { setHasMore(false); } } catch (error) { showAlert("error", error.response?.data?.data?.message || "팀 목록 조회 실패"); - console.log(error.response?.data); } finally { setIsFetching(false); } @@ -127,7 +124,7 @@ export default function Home() { } }; const handleScroll = () => { - if (!hasMore || isFetching) return; // 더 이상 데이터 없거나 이미 요청 중이면 중단 + if (!hasMore || isFetching || cards.length === 0) return; // 더 이상 데이터 없거나 이미 요청 중이면 중단 const { scrollTop, clientHeight, scrollHeight } = document.documentElement; // 스크롤이 거의 바닥이면 다음 데이터 요청 From 91860e19c2e34c9386531745396bb64018490a05 Mon Sep 17 00:00:00 2001 From: judymoody59 Date: Tue, 22 Apr 2025 00:00:42 +0900 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20home=20=EB=94=94=EB=B2=84=EA=B9=85?= =?UTF-8?q?=20=EC=BD=98=EC=86=94=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/home/home.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/home/home.js b/src/app/home/home.js index f8e7957..718f028 100644 --- a/src/app/home/home.js +++ b/src/app/home/home.js @@ -56,8 +56,12 @@ export default function Home() { const fetchTeams = async () => { - if (isFetching || !hasMore ) return; // 이미 요청 중이거나 더 이상 불러올 데이터 없으면 중단 + if (isFetching || !hasMore ) { // 이미 요청 중이거나 더 이상 불러올 데이터 없으면 중단 + console.log("fetchTeams 호출 중단됨: isFetching =", isFetching, ", hasMore =", hasMore); + return; + } + console.log("fetchTeams 호출됨 - lastTeamId:", lastTeamId); setIsFetching(true); try { const res = await axiosWithAuthorization.get( @@ -78,6 +82,7 @@ export default function Home() { if (newContent.length === 0) { // 데이터가 비어 있으면 더 이상 불러올 게 없음 + console.log("팀 없음!!!!"); setHasMore(false); return; } From f47816d044f0272d212e5e13e27aed8610cb1512 Mon Sep 17 00:00:00 2001 From: judymoody59 Date: Tue, 22 Apr 2025 00:08:30 +0900 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20team=20=EB=AA=A9=EB=A1=9D=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=20=EC=8B=A4=ED=8C=A8=EC=8B=9C=20=EB=AC=B4?= =?UTF-8?q?=ED=95=9C=20=ED=98=B8=EC=B6=9C=20=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/home/home.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/app/home/home.js b/src/app/home/home.js index 718f028..3f7760f 100644 --- a/src/app/home/home.js +++ b/src/app/home/home.js @@ -100,6 +100,8 @@ export default function Home() { } } catch (error) { showAlert("error", error.response?.data?.data?.message || "팀 목록 조회 실패"); + console.error("fetchTeams 에러 발생:", error); + setHasMore(false); } finally { setIsFetching(false); }