@@ -23,9 +23,17 @@ export function AppContextProvider({ children }: IProps) {
23
23
const [ completedQuizzesSlugs , setCompletedQuizzesSlugs ] = useState < string [ ] > (
24
24
[ ] ,
25
25
) ;
26
+ const [ sessionDataUser , setSessionDataUser ] = useState < any > ( null ) ;
26
27
27
28
const { data : sessionData } = useSession ( ) ;
28
29
30
+ useEffect ( ( ) => {
31
+ if ( sessionData ?. user && sessionData . user !== sessionDataUser ) {
32
+ setSessionDataUser ( sessionData . user ) ;
33
+ }
34
+ // eslint-disable-next-line react-hooks/exhaustive-deps
35
+ } , [ sessionData ] ) ;
36
+
29
37
// Requests
30
38
// - All
31
39
const {
@@ -36,7 +44,8 @@ export function AppContextProvider({ children }: IProps) {
36
44
undefined , // no input
37
45
{
38
46
// Disable request if no session data
39
- enabled : sessionData ?. user !== undefined ,
47
+ enabled : ! ! sessionDataUser ,
48
+ refetchOnWindowFocus : false ,
40
49
} ,
41
50
) ;
42
51
@@ -73,13 +82,13 @@ export function AppContextProvider({ children }: IProps) {
73
82
if ( projects && completedQuizzesSlugs . length !== 0 ) {
74
83
const projectsWithCompleteStatus = projects . map ( ( lesson ) => {
75
84
const completed = completedQuizzesSlugs . includes ( lesson . slug ) ;
76
- console . log ( { completed } ) ;
77
85
return { ...lesson , completed } ;
78
86
} ) ;
79
87
80
88
setProjects ( projectsWithCompleteStatus ) ;
81
89
}
82
- } , [ completedQuizzesSlugs , projects ] ) ;
90
+ // eslint-disable-next-line react-hooks/exhaustive-deps
91
+ } , [ completedQuizzesSlugs ] ) ;
83
92
84
93
return (
85
94
< AppContext . Provider
0 commit comments