Skip to content

Commit

Permalink
feat: (#275) 게시물 삭제 시 유저 정보 캐시 삭제하도록 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
chsua committed Aug 11, 2023
1 parent f80d454 commit b6c0525
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions frontend/src/hooks/query/post/useDeletePost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { deletePost } from '@api/post';

import { QUERY_KEY } from '@constants/queryKey';

export const useDeletePost = (postId: number) => {
export const useDeletePost = (postId: number, isLogged: boolean) => {
const queryClient = useQueryClient();

const { mutate, isError, error } = useMutation({
mutationFn: () => deletePost(postId),
onSuccess: () => {
queryClient.invalidateQueries([QUERY_KEY.POSTS]);
queryClient.invalidateQueries([QUERY_KEY.USER_INFO, isLogged]);
},
onError: error => {
window.console.log('게시물 삭제에 실패했습니다.', error);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/post/PostDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function PostDetailPage() {
isError: isPostError,
error: postError,
} = usePostDetail(!loggedInfo.isLoggedIn, postId);
const { mutate: deletePost } = useDeletePost(postId);
const { mutate: deletePost } = useDeletePost(postId, loggedInfo.isLoggedIn);
const { mutate: earlyClosePost } = useEarlyClosePost(postId);
const { data: commentData, isLoading: isCommentLoading } = useCommentList(postId);

Expand Down

0 comments on commit b6c0525

Please sign in to comment.