@@ -90,22 +90,32 @@ export default function withAuthentication(Component) {
90
90
}
91
91
} , [ params . teamId , teamId , dispatch , isLoggedIn ] ) ;
92
92
93
+ /*
94
+ Load V5 User Profile
95
+ */
93
96
useEffect ( ( ) => {
94
- if ( isLoggedIn ) {
97
+ // is user is logged-in, but V5 user profile is not loaded yet, then load it
98
+ if ( isLoggedIn && ! v5UserProfileLoading && ! v5UserProfile ) {
95
99
dispatch ( authLoadV5UserProfile ( ) ) ;
96
100
}
97
- } , [ dispatch , isLoggedIn ] ) ;
101
+ } , [ dispatch , isLoggedIn , v5UserProfileLoading , v5UserProfile ] ) ;
98
102
99
103
return (
100
104
< >
101
105
{ /* Show loading indicator until we know if user is logged-in or no.
102
106
Also, show loading indicator if we need to know team members but haven't loaded them yet.
103
107
or load v5 user profile but haven't loaded them yet.
104
108
In we got error during this process, show error */ }
105
- { isLoggedIn === null ||
106
- ( ( params . teamId && ! teamMembersLoaded || v5UserProfileLoading || v5UserProfileLoadingError ) && (
107
- < LoadingIndicator error = { authError || teamMembersLoadingError || v5UserProfileLoadingError } />
108
- ) ) }
109
+ { ( isLoggedIn === null ||
110
+ ( params . teamId && ! teamMembersLoaded ) ||
111
+ v5UserProfileLoading ||
112
+ v5UserProfileLoadingError ) && (
113
+ < LoadingIndicator
114
+ error = {
115
+ authError || teamMembersLoadingError || v5UserProfileLoadingError
116
+ }
117
+ />
118
+ ) }
109
119
110
120
{ /* Show component only if user is logged-in and if we don't need team members or we already loaded them */ }
111
121
{ isLoggedIn === true &&
0 commit comments