Repository navigation
perf: 산 좋아요 탭당 요청을 1건으로 줄이고 하트 상태를 likedByMe로 판정 - #230
Merged
Merged
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 6 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
|
확인했습니다! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🧩 작업 내용
저장한 산 하트가 버벅인다는 제보를 보다가, 요청 개수와 좋아요 상태 판정 구조 두 군데에 문제가 있어 함께 정리했습니다.
POST단일 토글로 통일하고 응답의liked로 캐시를 갱신 — 따라 나가던GET /api/mountains/likes를 제거해 탭당 요청 1건likedByMe기반으로 전환createdAt DESC정렬에 맞춤)DELETE /api/mountains/{id}/like호출 제거isPending→ref로 교체해 같은 프레임 더블탭 차단🐞 같이 고친 버그
저장한 산이 11개를 넘으면 하트가 틀어졌습니다.
기존에는
GET /api/mountains/likes를page/size없이 1회만 호출하고, 그 1페이지content로 앱 전체의 하트 on/off를 판정했습니다. 서버 기본 page size가 10이라 11번째 이후로 저장한 산은 상세에 들어가도 하트가 꺼진 채 보이고, 그 하트를 누르면 이미 좋아요한 산에 좋아요 요청이 또 나갔습니다.likedByMe기반으로 바꾸면서 저장 목록 페이지네이션과 무관해졌습니다.더블탭이 요청 2건을 보냈습니다.
isPending은 렌더 시점 값이라 같은 프레임에 두 번 눌리면 두 호출 모두 가드를 통과합니다. 테스트로 재현(POST 2건)한 뒤ref로 동기 잠금했습니다. 서버에서 간헐적으로 관측된 동시 토글 500의 클라이언트 쪽 원인으로 보입니다.📱 관련 화면 / 기능
🔍 변경 전후
POST+GET /likes(2건)POST(1건)DELETE(스펙에 없음)POST(1건)GET /likeslikedByMePOST단일 토글은 코스 좋아요(use-toggle-course-like.ts)·게시글 좋아요(use-post-like.ts)와 같은 컨벤션입니다. 산만POST+DELETE를 쓰고 있었습니다.✅ 검증
tsc --noEmit통과expo lint0 errors (warning 19건은 모두 기존 파일)jest42건 통과 (신규 8건)런타임 미검증 — 리뷰 때 확인 부탁드립니다
GET /api/mountains/{id}응답의mountain.likedByMe가 실제로 채워지는지. 안 채워지면 상세 하트가 항상 꺼져 보입니다 (필드는 스펙에 존재)💬 기타 사항
GET /api/mountains/likes응답에likedByMe를 추가하는 안은 필요 없어졌습니다. 하트가 더 이상 저장 목록을 읽지 않습니다createdAt DESC, id DESC정렬 고정과 멱등 토글 작업이 함께 진행 중입니다. 맨 앞 삽입은 그 정렬을 전제로 합니다page/size없이 1페이지만 불러와 최대 10개만 보입니다. 서버 정렬 고정이 머지된 뒤 무한스크롤로 붙이는 게 맞아 보여 이번 범위에서 제외했습니다🤖 Generated with Claude Code