-
Notifications
You must be signed in to change notification settings - Fork 3
refactor: 프로젝트 삭제 로직 useDeleteProjectsMutation 훅으로 통합 및 리팩토링 #74
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
refactor: 프로젝트 삭제 로직 useDeleteProjectsMutation 훅으로 통합 및 리팩토링 #74
Conversation
tkyoun0421
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
정말 고생 많으셨습니다 💯
| // 문서 ID를 직접 생성하여 삭제 (더 효율적) | ||
| const deletePromises = projectIds.map((projectId) => { | ||
| const likeId = `${userId}_${projectId}`; | ||
| return deleteDoc(doc(db, "likes", likeId)); | ||
| }); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오호.. 랜덤 ID가 아닌 부분이 이런 장점이 있었네여
firebase 또 쓸 일이 있다면 써먹을 수 있을 것 같네요 배워갑니다 💯
| const invalidateLikeQueries = async (): Promise<void> => { | ||
| const queries = [ | ||
| [queryKeys.myLikedProjects, "details"], | ||
| [queryKeys.myLikedProjects, "ids"], | ||
| [queryKeys.projectLike], | ||
| [queryKeys.projectLikedUser], | ||
| [queryKeys.projects], // 홈페이지, 프로젝트 찾기 페이지 동기화 | ||
| ]; | ||
|
|
||
| await Promise.all( | ||
| queries.map((queryKey) => queryClient.invalidateQueries({ queryKey })) | ||
| ); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
비동기로 안 해도 될 것 같다는?? 🐌🐌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
호오 그러쿤욥 ! 사실 이 부분이 이전에 동기처리로 되어있었는데 너무 복잡해보여서 바꿨습니당..ㅎㅎ
| useEffect(() => { | ||
| if (appliedProjectsData) { | ||
| setAppliedProjects(appliedProjectsData); | ||
| } | ||
| }, [appliedProjectsData, setAppliedProjects]); | ||
|
|
||
| // 좋아요한 프로젝트 데이터를 store에 동기화 | ||
| useEffect(() => { | ||
| if (myLikedProjectsData) { | ||
| setLikeProjects(myLikedProjectsData); | ||
| } | ||
| }, [myLikedProjectsData, setLikeProjects]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요게 어떤 로직인지 궁금합니다! 데이터를 받아오면 store에 동기화 하는 코드일까여?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 지원한프로젝트랑 좋아요한프로젝트를 스토어에 동기화하는 코드에욥 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그렇군여! 그럼 쿼리에서 관리하지 않으신가요??!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
쿼리에서 관리하고 있고, store는 전역 상태 동기화/빠른 접근을 위해 추가로 사용하는 보조 수단이에요!
9244cfa
into
amicable-development-center:develop
개요
좋아요 삭제 후 상세페이지에선 좋아요가 남아있는 이슈
변경 사항
구현 내용
개발 후기 및 개선사항
이번 작업에서 배운 점
어려웠던 점 / 에로사항
다음에 개선하고 싶은 점
팀원들과 공유하고 싶은 팁