Repository navigation
fix: 새로고침 후 기사님 찜 상태가 초기화되는 문제 수정 #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
408b74b
fix: 새로고침 후 기사님 찜 상태가 초기화되는 문제 수정
yooseohyeon 4d5683f
fix: 기사님 목록 캐시를 사용자별로 분리
yooseohyeon ffb7747
fix: 인증 완료 후 기사님 목록 observer 재연결
yooseohyeon 2035287
fix: 기사 계정에서 고객용 찜 사이드바 숨김
yooseohyeon 937c9a1
fix: 세션 전환 시 사용자 쿼리 캐시 초기화
yooseohyeon c2e6b57
fix: 찜한 기사님 목록 캐시를 사용자별로 분리
yooseohyeon e4ab871
fix: 캐시 초기화 세션 식별 로직 통일
yooseohyeon c584bd6
fix: 사용자 식별 전 인증 쿼리 실행 방지
yooseohyeon 966d2f6
fix: 세션 전환 시 전역 쿼리 캐시 초기화 제거
yooseohyeon 4526896
fix: 찜 낙관적 업데이트를 사용자 캐시로 제한
yooseohyeon 147a0b0
fix: 기사 상세 캐시를 사용자별로 분리 및 인증 복구 중 guest 데이터 노출 방지
yooseohyeon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,29 @@ | ||
| "use client"; | ||
|
|
||
| import { getMovers } from "@/lib/api/movers"; | ||
| import { hasAuthSession } from "@/lib/auth/session"; | ||
| import { QUERY_KEYS } from "@/lib/constants/queryKeys"; | ||
| import { toMoversListQuery, type MoversSearchParamsState } from "@/lib/utils/moversSearchParams"; | ||
| import { useApiInfiniteQuery } from "@/hooks/queries/useApiInfiniteQuery"; | ||
| import { useIsClient } from "@/hooks/useIsClient"; | ||
| import { useAuthStore } from "@/stores/useAuthStore"; | ||
|
|
||
| const MOVERS_LIST_STALE_TIME_MS = 60 * 1000; | ||
|
|
||
| export function useMovers(filters: MoversSearchParamsState) { | ||
| const listQuery = toMoversListQuery(filters); | ||
| const isClient = useIsClient(); | ||
| // SSR prefetch는 서버에 access token이 없어 비회원 응답일 수 있음 → 로그인 시 즉시 재검증 | ||
| const staleTime = isClient && hasAuthSession() ? 0 : MOVERS_LIST_STALE_TIME_MS; | ||
| const hasHydrated = useAuthStore((state) => state.hasHydrated); | ||
| const isCheckingAuth = useAuthStore((state) => state.isCheckingAuth); | ||
| const isAuthenticated = useAuthStore((state) => state.isAuthenticated); | ||
| const isAuthReady = hasHydrated && !isCheckingAuth; | ||
| const authScope = isAuthenticated ? "authenticated" : "guest"; | ||
|
yooseohyeon marked this conversation as resolved.
Resolved
|
||
|
|
||
| return useApiInfiniteQuery({ | ||
| queryKey: [...QUERY_KEYS.MOVERS.LIST, listQuery], | ||
| queryKey: [...QUERY_KEYS.MOVERS.LIST, authScope, listQuery], | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| queryFn: ({ pageParam }) => getMovers({ ...listQuery, page: pageParam }), | ||
| initialPageParam: 1, | ||
| getNextPageParam: (lastPage) => | ||
| lastPage.pagination.hasNext ? lastPage.pagination.page + 1 : undefined, | ||
| staleTime, | ||
| enabled: isAuthReady, | ||
| // 로그인 응답의 isFavorite는 세션 복구 직후 항상 서버에서 다시 확인합니다. | ||
| staleTime: isAuthenticated ? 0 : MOVERS_LIST_STALE_TIME_MS, | ||
| }); | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.