@@ -14,7 +14,7 @@ import PostContent from '../../components/post/PostContent';
14
14
import PostComments from './PostComments' ;
15
15
import postSlice from '../../modules/post' ;
16
16
import PostViewerProvider from '../../components/post/PostViewerProvider' ;
17
- import { useUserId } from '../../lib/hooks/useUser' ;
17
+ import useUser , { useUserId } from '../../lib/hooks/useUser' ;
18
18
import { useQuery , useMutation , useApolloClient } from '@apollo/react-hooks' ;
19
19
import { withRouter , RouteComponentProps } from 'react-router-dom' ;
20
20
import { prepareEdit } from '../../modules/write' ;
@@ -97,6 +97,7 @@ const PostViewer: React.FC<PostViewerProps> = ({
97
97
if ( ! userLogo || ! userLogo . title ) return `${ username } .log` ;
98
98
return userLogo . title ;
99
99
} , [ userLogo , username ] ) ;
100
+ const user = useUser ( ) ;
100
101
101
102
const { error, data } = readPost ;
102
103
@@ -213,6 +214,7 @@ const PostViewer: React.FC<PostViewerProps> = ({
213
214
214
215
const onLikeToggle = async ( ) => {
215
216
if ( loadingLike || loadingUnlike ) return ;
217
+
216
218
const variables = {
217
219
id : post . id ,
218
220
} ;
@@ -230,6 +232,10 @@ const PostViewer: React.FC<PostViewerProps> = ({
230
232
// });
231
233
232
234
try {
235
+ if ( ! user ) {
236
+ toast . error ( '로그인 후 이용해주세요.' ) ;
237
+ return ;
238
+ }
233
239
if ( post . liked ) {
234
240
client . writeFragment ( {
235
241
id : `Post:${ post . id } ` ,
0 commit comments