Skip to content

Commit 317a87e

Browse files
committed
fix: handle post cache
1 parent b57601f commit 317a87e

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

src/components/common/FollowButton.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ import { gql } from 'apollo-boost';
88
import useUser from '../../lib/hooks/useUser';
99
import { toast } from 'react-toastify';
1010
import { themedPalette } from '../../lib/styles/themes';
11-
import palette from '../../lib/styles/palette';
1211

1312
export interface PostFollowButtonProps {
1413
followingUserId: string;
1514
followed: boolean | undefined;
15+
postId: string;
1616
}
1717

1818
const FollowButton: React.FC<PostFollowButtonProps> = ({
1919
followingUserId,
2020
followed,
21+
postId,
2122
}) => {
2223
const client = useApolloClient();
2324
const currentUser = useUser();
@@ -51,6 +52,7 @@ const FollowButton: React.FC<PostFollowButtonProps> = ({
5152

5253
const variables = {
5354
following_user_id: followingUserId,
55+
post_id: postId,
5456
};
5557

5658
const followFragment = gql`

src/containers/post/PostViewer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ const PostViewer: React.FC<PostViewerProps> = ({
429429
<FollowButton
430430
followed={post.user.is_followed}
431431
followingUserId={post.user.id}
432+
postId={post.id}
432433
/>
433434
}
434435
/>
@@ -446,6 +447,7 @@ const PostViewer: React.FC<PostViewerProps> = ({
446447
<FollowButton
447448
followed={post.user.is_followed}
448449
followingUserId={post.user.id}
450+
postId={post.id}
449451
/>
450452
}
451453
/>

src/lib/graphql/user.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,18 @@ export const CONFIRM_CHANGE_EMAIL = gql`
184184
`;
185185

186186
export const FOLLOW_USER = gql`
187-
mutation Follow($following_user_id: ID!) {
188-
follow(following_user_id: $following_user_id)
187+
mutation Follow($following_user_id: ID!, $post_id: ID!) {
188+
follow(following_user_id: $following_user_id, post_id: $post_id) {
189+
id
190+
}
189191
}
190192
`;
191193

192194
export const UNFOLLOW_USER = gql`
193-
mutation Unfollow($following_user_id: ID!) {
194-
unfollow(following_user_id: $following_user_id)
195+
mutation Unfollow($following_user_id: ID!, $post_id: ID!) {
196+
unfollow(following_user_id: $following_user_id, post_id: $post_id) {
197+
id
198+
}
195199
}
196200
`;
197201

src/pages/velog/UserPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const UserPage: React.FC<UserPageProps> = ({ match, location }) => {
2121
useEffect(() => {
2222
window.location.href = `${process.env
2323
.REACT_APP_CLIENT_V3_HOST!}/@${username}/posts`;
24-
}, []);
24+
}, [username]);
2525

2626
return (
2727
<UserPageBlock>

0 commit comments

Comments
 (0)