@@ -8,7 +8,6 @@ import { getRepoConfig } from '@/lib/api/github';
8
8
import datetime from '@/lib/date-time' ;
9
9
import { useRepoStore } from '@/stores/repo.store' ;
10
10
import { Folder , Plus , Search } from 'lucide-react' ;
11
- import { useSession } from 'next-auth/react' ;
12
11
import { useCallback , useEffect } from 'react' ;
13
12
import { toast } from 'sonner' ;
14
13
@@ -18,17 +17,16 @@ interface Props {
18
17
}
19
18
20
19
export default function RepoContents ( { repo, setIsConfigDialogOpen } : Props ) {
21
- const { status } = useSession ( ) ;
22
- const stableSession = useStableSession ( ) ;
20
+ const { session, status } = useStableSession ( ) ;
23
21
const { setConfig, setIsValid } = useRepoStore ( ( state ) => state ) ;
24
22
const { contents, isLoading } = useRepoContents ( repo ) ;
25
23
26
24
const loadConfigFilePromise = useCallback (
27
25
( ) =>
28
26
new Promise < void > ( async ( resolve , reject ) => {
29
27
const _config = await getRepoConfig ( {
30
- accessToken : stableSession ?. accessToken ,
31
- username : stableSession ?. user ?. username ,
28
+ accessToken : session ?. accessToken ,
29
+ username : session ?. user ?. username ,
32
30
repo,
33
31
} ) ;
34
32
@@ -42,11 +40,11 @@ export default function RepoContents({ repo, setIsConfigDialogOpen }: Props) {
42
40
setIsValid ( true ) ;
43
41
}
44
42
} ) ,
45
- [ stableSession , repo , setIsConfigDialogOpen , setIsValid , setConfig ] ,
43
+ [ session , repo , setIsConfigDialogOpen , setIsValid , setConfig ] ,
46
44
) ;
47
45
48
46
useEffect ( ( ) => {
49
- if ( ! stableSession ) return ;
47
+ if ( ! session ) return ;
50
48
51
49
// call toast to init config
52
50
// and show some feedback
@@ -61,15 +59,15 @@ export default function RepoContents({ repo, setIsConfigDialogOpen }: Props) {
61
59
description : 'Failed to load repo config file.' ,
62
60
} ,
63
61
} ) ;
64
- } , [ stableSession , loadConfigFilePromise ] ) ;
62
+ } , [ session , loadConfigFilePromise ] ) ;
65
63
66
64
return (
67
65
< div className = "col-span-2 flex flex-col gap-2" >
68
66
< div className = "flex items-center gap-4" >
69
67
< div className = "flex items-center gap-2" >
70
68
< Avatar className = "size-5" >
71
- < AvatarImage src = { stableSession ?. user ?. image ?? undefined } />
72
- < AvatarFallback > { stableSession ?. user ?. name ?. [ 0 ] } </ AvatarFallback >
69
+ < AvatarImage src = { session ?. user ?. image ?? undefined } />
70
+ < AvatarFallback > { session ?. user ?. name ?. [ 0 ] } </ AvatarFallback >
73
71
</ Avatar >
74
72
< span className = "text-muted-foreground/50 text-xl" > /</ span >
75
73
< Button variant = { 'ghost' } className = "px-2 font-bold" asChild >
@@ -116,7 +114,7 @@ export default function RepoContents({ repo, setIsConfigDialogOpen }: Props) {
116
114
< button className = "text-sm hover:underline" > { content . name } </ button >
117
115
</ div >
118
116
< a
119
- href = { `https://github.com/${ stableSession ?. user ?. username } /${ repo } /commit/${ content . lastCommit . sha } ` }
117
+ href = { `https://github.com/${ session ?. user ?. username } /${ repo } /commit/${ content . lastCommit . sha } ` }
120
118
target = "_blank"
121
119
rel = "noreferrer noopener"
122
120
className = "text-muted-foreground col-span-2 text-sm hover:underline"
0 commit comments