Skip to content

Commit

Permalink
Merge pull request #337 from depromeet/fix/QA-9
Browse files Browse the repository at this point in the history
피드 컴포넌트에 팔로우, 언팔로우 로직 추가
  • Loading branch information
YOOJS1205 authored May 7, 2024
2 parents ef825e3 + 15817b7 commit 06ddfff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/components/feed/Feed/FeedProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Image, { ImageProps } from 'next/image';
import { useRouter } from 'next/navigation';

import { usePatchFollow } from '@hooks/api/usePatchFollow';
import DefaultProfileImage from 'public/assets/image/default_profile.png';

interface FeedProfileProps extends Omit<ImageProps, 'id'> {
Expand All @@ -22,17 +23,14 @@ export default function FeedProfile({
...props
}: FeedProfileProps) {
const { push } = useRouter();
const { mutate: patchFollow } = usePatchFollow();

const handleClickProfile = () => {
push(`/profile/${userId}`);
};

const handleClickFollowButton = () => {
if (isFollowed) {
console.log('팔로우');
} else {
console.log('팔로우 취소');
}
patchFollow(userId);
};

return (
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/api/usePatchFollow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export const usePatchFollow = (): UseMutationResult<
queryKey: ['get-following-list'],
refetchType: 'all',
});
queryClient.invalidateQueries({
queryKey: ['get-feed-list', {}],
refetchType: 'all',
});
if (userId !== undefined) {
queryClient.invalidateQueries({
queryKey: ['get-userProfile', userId],
Expand Down

0 comments on commit 06ddfff

Please sign in to comment.