Skip to content

Commit 60020e4

Browse files
authored
Merge pull request velopert#14 from velopert/fix/nonuser-like
Fix velopert#13
2 parents eb6c812 + 8afdaf8 commit 60020e4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/containers/post/PostViewer.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import PostContent from '../../components/post/PostContent';
1414
import PostComments from './PostComments';
1515
import postSlice from '../../modules/post';
1616
import PostViewerProvider from '../../components/post/PostViewerProvider';
17-
import { useUserId } from '../../lib/hooks/useUser';
17+
import useUser, { useUserId } from '../../lib/hooks/useUser';
1818
import { useQuery, useMutation, useApolloClient } from '@apollo/react-hooks';
1919
import { withRouter, RouteComponentProps } from 'react-router-dom';
2020
import { prepareEdit } from '../../modules/write';
@@ -97,6 +97,7 @@ const PostViewer: React.FC<PostViewerProps> = ({
9797
if (!userLogo || !userLogo.title) return `${username}.log`;
9898
return userLogo.title;
9999
}, [userLogo, username]);
100+
const user = useUser();
100101

101102
const { error, data } = readPost;
102103

@@ -213,6 +214,7 @@ const PostViewer: React.FC<PostViewerProps> = ({
213214

214215
const onLikeToggle = async () => {
215216
if (loadingLike || loadingUnlike) return;
217+
216218
const variables = {
217219
id: post.id,
218220
};
@@ -230,6 +232,10 @@ const PostViewer: React.FC<PostViewerProps> = ({
230232
// });
231233

232234
try {
235+
if (!user) {
236+
toast.error('로그인 후 이용해주세요.');
237+
return;
238+
}
233239
if (post.liked) {
234240
client.writeFragment({
235241
id: `Post:${post.id}`,

0 commit comments

Comments
 (0)