File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -2,13 +2,16 @@ import axios from 'axios';
2
2
import { useAtomValue } from 'jotai' ;
3
3
import { useEffect , useState } from 'react' ;
4
4
import { repoAtom } from '@/state/repoAtom' ;
5
+ import { useSession } from 'next-auth/react' ;
5
6
6
7
export function useGetRepo ( ) {
7
8
const [ isReported , setIsReported ] = useState ( false ) ;
9
+ const session = useSession ( ) ;
8
10
const repo = useAtomValue ( repoAtom ) ;
9
11
10
12
useEffect ( ( ) => {
11
13
async function checkRepo ( ) {
14
+ if ( ! session . data ?. user ) return ;
12
15
if ( ! repo ) return ;
13
16
const repoId = repo ?. id ;
14
17
const res = await axios . get ( `/api/check-repo?repoId=${ repoId } ` ) ;
@@ -18,7 +21,7 @@ export function useGetRepo() {
18
21
return setIsReported ( true ) ;
19
22
}
20
23
checkRepo ( ) ;
21
- } , [ repo ] ) ;
24
+ } , [ repo , session ] ) ;
22
25
23
26
return isReported ;
24
27
}
You can’t perform that action at this time.
0 commit comments