Skip to content

[FE] fix: 로그아웃 시, 변경된 사용자 프로필 캐시 적용안되는 오류 수정 #1173

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 6 commits into from
Feb 23, 2025

Conversation

BadaHertz52
Copy link
Contributor


🚀 어떤 오류였나요?

홈 페이지와 연결 페이지에서 로그아웃 시, 로그인 된 이전의 사용자 프로필 쿼리를 그대로 사용하는 오류가 발생했습니다.

🔥 어떻게 해결했나요 ?

해결 방법

query.clear는 쿼리를 재리패치 않아, 사용자 프로필만 무효화하고 그 외의 쿼리를 삭제했습니다.

모든 쿼리를 삭제가 아닌 무효화하면, 무효화 쿼리가 적용하기 까지 시간이 걸려 로그아웃 후 이전/다음으로 회원용 페이지에 접근할 수 있습니다. 그래서 로그인 여부를 확인하는 사용자 프로필만 무효화해 리패치가 일어나도록 하고, 그 외는 쿼리는 리패치가 일어나지 않도록 removeQueries 로 삭제했습니다.

추가 구현

release에서 QA시, 오류 아이콘 로딩이 느려서 스켈레톤 적용했습니다. 겸사겸사 깃허브 프로필에도 적용했습니다.

📝 어떤 부분에 집중해서 리뷰해야 할까요?

  • 로컬에서 막 사용해서, 오류가 없는 지 확인해주세요.

📚 참고 자료, 할 말

  • 🙏 이번 배포 마지막 쿼리 버그여랴...

Copy link
Contributor

@ImxYJL ImxYJL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제 로컬에서는 로그인이 불안정해서(요청이 자꾸 실제 dev 서버로 갔다가 msw 응답 받다가 왔다갔다...) 로컬 테스트는아직 못 했지만 코드만이라도 보고 리뷰 남깁니다...
로그인 도입 덕분에 리액트 쿼리 캐시에 대해 이것저것 알아가네요 😅

@@ -19,10 +19,14 @@ const useOAuthLogout = () => {

const removeAllQueriesExceptUserProfile = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

savedKey를 처리하는 로직이 추가돼서 함수 이름을 바꿔야 할 것 같아요(제안: removeQueriesExceptSavedKeys)

Comment on lines 25 to 31
if (!query.queryKey[0]) return;
if (query.queryKey[0] !== OAUTH_QUERY_KEY.userProfile) {

const isSaved = savedQueryKeys.some((key) => key === query.queryKey[0]);

if (!isSaved) {
queryClient.removeQueries(query.queryKey[0]);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forEach 본문을

const key = queryKey[0];
    if (key && !savedQueryKeys.includes(key)) {
      queryClient.removeQueries(key);
    }

처럼 includes를 사용하면 더 간결해질 것 같습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아쉽게도 {}' 형식의 인수는 'string' 형식의 매개 변수에 할당될 수 없습니다.ts(2345) const key: {} 라는 오류가 뜨네요.

Copy link
Contributor

@chysis chysis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

덕분에 clear, remove, invalidate의 차이를 알게 되었어요🔥
이미지 스켈레톤 처리까지 고생했어요

Copy link
Contributor

@soosoo22 soosoo22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰미 사이트 들어가서 확인해보니 홈에서 로그아웃했을 경우, 리뷰 받아오기 버튼이 보이네여,,,😭 캐싱 문제가 여러모로 많네여...

@BadaHertz52 BadaHertz52 merged commit 3c7f273 into develop Feb 23, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[FE] fix: 홈 페이지에서 로그아웃 시, 쿼리가 리패치되지 않는 오류를 수정한다
4 participants