Skip to content
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

✨ 좋아요 싫어요 낙관적 업데이트 적용 #322

Merged
merged 2 commits into from
Oct 5, 2023

Conversation

khj0426
Copy link
Collaborator

@khj0426 khj0426 commented Oct 4, 2023

- 목적

관련 이슈: #


- 주요 변경 사항

  • useMutation을 쓰면 낙관적 업데이트를 되게 쉽게 구현할 수 있어서 좋아요 싫어요 부분을 낙관적업데이트로 구현하게 수정했습니다.

기타 사항 (선택)


- 스크린샷 (선택)

chrome-capture-2023-9-4.webm

@khj0426 khj0426 self-assigned this Oct 4, 2023
Copy link
Member

@leeminhee119 leeminhee119 left a comment

Choose a reason for hiding this comment

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

프로젝트 끝나자마자 바로 리팩토링 열심히 하시는 효중님... 👍 진짜 멋지십니다 저도 부지런히 리팩토링 해야겠어요 !!!

await queryClient.invalidateQueries(['post', initPost._id])
},
},
)
Copy link
Member

Choose a reason for hiding this comment

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

useMutation을 활용한 낙관적 업데이트..! 공식 문서에 있는 거 보긴 했지만 반영은 못했는데 저도 팔로우 관련해서 리팩토링 할 때 잘 참고해보겠습니다 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

되게 편하게 적용할 수 있더라고요 !! 화이팅임니다.!!

initDisLikePost: Post
}

export function useLikeQuery(postId: string, initPost: Post) {
Copy link
Member

Choose a reason for hiding this comment

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

좋아요 포스트를 가져오는 쿼리같은데 포스트를 가져온다는 의미를 이름에 담아보면 어떨까요??

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

오오 좋습니당

})
.finally(() => {
setLoading(false)
})
Copy link
Member

Choose a reason for hiding this comment

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

isLikePostFetching을 걸어줘서 이게 필요 없어진 건가요 ?? 👍👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

맞아요! !!

Copy link
Member

@oaoong oaoong left a comment

Choose a reason for hiding this comment

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

좋네요!!


export function useLikeMutate({ initPost, initDisLikePost }: useLikeProps) {
const queryClient = useQueryClient()
const { currentUser } = useCurrentUser()
Copy link
Member

Choose a reason for hiding this comment

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

useAuth()로 대체하기로 하지 않았나요?? 그것도 그렇지만 여기서 의존적으로 불러오는 것보다는 전달받아 사용하면 좋을 것 같습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

오오그게 더 좋겠네욤

@khj0426 khj0426 merged commit 26c2c7a into develop Oct 5, 2023
1 check passed
@khj0426 khj0426 deleted the bug-post-update branch October 6, 2023 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants