From 5781431c94b109604c61f67513548c1575fe749b Mon Sep 17 00:00:00 2001 From: youjin-hub Date: Mon, 24 Nov 2025 06:25:00 +0900 Subject: [PATCH 1/6] =?UTF-8?q?fix:=20=EB=8C=93=EA=B8=80=20=ED=97=A4?= =?UTF-8?q?=EB=8D=94=20=EC=B9=B4=EC=9A=B4=ED=8A=B8=EB=A5=BC=20=EC=84=9C?= =?UTF-8?q?=EB=B2=84=20total=20=EA=B8=B0=EC=A4=80=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../freeboard/[freeboardId]/components/CommentList.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/web/src/app/main/community/freeboard/[freeboardId]/components/CommentList.tsx b/apps/web/src/app/main/community/freeboard/[freeboardId]/components/CommentList.tsx index 1698db26..e8ec2ee4 100644 --- a/apps/web/src/app/main/community/freeboard/[freeboardId]/components/CommentList.tsx +++ b/apps/web/src/app/main/community/freeboard/[freeboardId]/components/CommentList.tsx @@ -58,12 +58,12 @@ export default function CommentList({ ); }, [data]); - const latestTotal = + const firstPageTotal = data?.pages && data.pages.length > 0 - ? data.pages[data.pages.length - 1]?.total + ? data.pages[0]?.total : undefined; - const headerCount = latestTotal ?? initialCount ?? comments.length; + const headerCount = firstPageTotal ?? initialCount ?? 0; return (
From 11c4bfd8ab23a5c11accb1124d138fd15ebce20f Mon Sep 17 00:00:00 2001 From: youjin-hub Date: Mon, 24 Nov 2025 06:49:41 +0900 Subject: [PATCH 2/6] =?UTF-8?q?refactor:=20=EC=A2=8B=EC=95=84=EC=9A=94=20?= =?UTF-8?q?=EC=B9=B4=EC=9A=B4=ED=8A=B8=20=EB=B3=B4=EC=A0=95=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=EC=9D=84=20=EA=B3=B5=ED=86=B5=20=EC=9C=A0=ED=8B=B8?= =?UTF-8?q?=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../[freeboardId]/components/LikeButtonComment.tsx | 6 ++---- .../freeboard/[freeboardId]/components/LikeButtonPost.tsx | 8 +++----- apps/web/src/utils/clampCount.ts | 6 ++++++ 3 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 apps/web/src/utils/clampCount.ts diff --git a/apps/web/src/app/main/community/freeboard/[freeboardId]/components/LikeButtonComment.tsx b/apps/web/src/app/main/community/freeboard/[freeboardId]/components/LikeButtonComment.tsx index 1e348383..dc50be7c 100644 --- a/apps/web/src/app/main/community/freeboard/[freeboardId]/components/LikeButtonComment.tsx +++ b/apps/web/src/app/main/community/freeboard/[freeboardId]/components/LikeButtonComment.tsx @@ -8,6 +8,7 @@ import { useToast } from '@/hooks/ui/useToast'; import { formatCappedCount } from '@/utils/formatCount'; import { getGetFreeboardCommentsByCursorQueryKey } from '@/generated/api/endpoints/freeboard-comment/freeboard-comment'; import { useToggleFreeboardCommentLike } from '@/generated/api/endpoints/freeboard-comment-like/freeboard-comment-like'; +import { clampCount } from '@/utils/clampCount'; interface LikeButtonCommentProps { postId: number; @@ -16,9 +17,6 @@ interface LikeButtonCommentProps { initialLikeCount: number; } -// 음수 방지(보정) 헬퍼 -const clampMin0 = (n: number) => (n < 0 ? 0 : n); - /** * 댓글 좋아요 버튼 * @@ -66,7 +64,7 @@ export default function LikeButtonComment({ setLiked((prev) => { const next = !prev; const delta = next ? 1 : -1; - setLikeCount((count) => clampMin0(count + delta)); + setLikeCount((count) => clampCount(count + delta)); return next; }); diff --git a/apps/web/src/app/main/community/freeboard/[freeboardId]/components/LikeButtonPost.tsx b/apps/web/src/app/main/community/freeboard/[freeboardId]/components/LikeButtonPost.tsx index b4b8541c..46cbdc59 100644 --- a/apps/web/src/app/main/community/freeboard/[freeboardId]/components/LikeButtonPost.tsx +++ b/apps/web/src/app/main/community/freeboard/[freeboardId]/components/LikeButtonPost.tsx @@ -9,6 +9,7 @@ import { useToast } from '@/hooks/ui/useToast'; import { FreeboardDetailResponse } from '@/generated/api/models'; import { getGetFreeboardPostQueryKey } from '@/generated/api/endpoints/freeboard/freeboard'; import { useToggleFreeboardLike } from '@/generated/api/endpoints/freeboard-like/freeboard-like'; +import { clampCount } from '@/utils/clampCount'; interface LikeButtonPostProps { postId: number; @@ -16,9 +17,6 @@ interface LikeButtonPostProps { initialLikeCount: number; } -// 음수 방지(보정) 헬퍼 -const clampMin0 = (n: number) => (n < 0 ? 0 : n); - /** * 게시글 좋아요 버튼 * @@ -69,7 +67,7 @@ export default function LikeButtonPost({ setLiked((prev) => { const next = !prev; const delta = next ? 1 : -1; - setLikeCount((count) => clampMin0(count + delta)); + setLikeCount((count) => clampCount(count + delta)); return next; }); @@ -79,7 +77,7 @@ export default function LikeButtonPost({ (old) => { if (!old) return old; const nextLiked = !(old.isLiked ?? false); - const nextCount = clampMin0( + const nextCount = clampCount( old.likeCount + (nextLiked ? 1 : -1), ); return { diff --git a/apps/web/src/utils/clampCount.ts b/apps/web/src/utils/clampCount.ts new file mode 100644 index 00000000..76aedb74 --- /dev/null +++ b/apps/web/src/utils/clampCount.ts @@ -0,0 +1,6 @@ +/** + * 카운트 값이 min(기본 0) 아래로 내려가지 않도록 보정합니다. + */ +export const clampCount = (n: number, min = 0) => { + return Math.max(n, min); +}; From 13bad330e554c101966cce24393619a937c4efb2 Mon Sep 17 00:00:00 2001 From: youjin-hub Date: Mon, 24 Nov 2025 12:00:10 +0900 Subject: [PATCH 3/6] =?UTF-8?q?fix(likeButton):=20=EC=9D=B8=EC=A6=9D=20?= =?UTF-8?q?=EB=B3=B5=EC=9B=90=20UI=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/LikeButtonComment.tsx | 21 +------------------ .../components/LikeButtonPost.tsx | 19 +---------------- 2 files changed, 2 insertions(+), 38 deletions(-) diff --git a/apps/web/src/app/main/community/freeboard/[freeboardId]/components/LikeButtonComment.tsx b/apps/web/src/app/main/community/freeboard/[freeboardId]/components/LikeButtonComment.tsx index dc50be7c..42dd6b8d 100644 --- a/apps/web/src/app/main/community/freeboard/[freeboardId]/components/LikeButtonComment.tsx +++ b/apps/web/src/app/main/community/freeboard/[freeboardId]/components/LikeButtonComment.tsx @@ -3,7 +3,7 @@ import { useEffect, useState } from 'react'; import { ThumbsUp } from 'lucide-react'; import { useQueryClient } from '@tanstack/react-query'; -import { useAuthGuard, useAuthRestore } from '@/hooks/useAuth'; +import { useAuthGuard } from '@/hooks/useAuth'; import { useToast } from '@/hooks/ui/useToast'; import { formatCappedCount } from '@/utils/formatCount'; import { getGetFreeboardCommentsByCursorQueryKey } from '@/generated/api/endpoints/freeboard-comment/freeboard-comment'; @@ -30,7 +30,6 @@ export default function LikeButtonComment({ initialLiked, initialLikeCount, }: LikeButtonCommentProps) { - const { isRestoring, isAuthenticated } = useAuthRestore(); const queryClient = useQueryClient(); const toast = useToast(); const { guard } = useAuthGuard(); @@ -102,23 +101,6 @@ export default function LikeButtonComment({ toggleLike.mutate({ freeboardId: postId, commentId }); }); - // 인증 복원 중임을 명시(시각적 피드백) - if (isRestoring) { - return ( - - ); - } - return ( - ); - } - return (