@@ -19,6 +19,7 @@ import {
1919 authUserSuccess ,
2020 authUserError ,
2121 authLoadTeamMembers ,
22+ authLoadV5UserProfile ,
2223 authClearTeamMembers ,
2324} from "./actions" ;
2425import { decodeToken } from "tc-auth-lib" ;
@@ -34,6 +35,9 @@ export default function withAuthentication(Component) {
3435 teamId,
3536 teamMembersLoaded,
3637 teamMembersLoadingError,
38+ v5UserProfile,
39+ v5UserProfileLoading,
40+ v5UserProfileLoadingError,
3741 } = useSelector ( ( state ) => state . authUser ) ;
3842 const params = useParams ( ) ;
3943
@@ -86,18 +90,27 @@ export default function withAuthentication(Component) {
8690 }
8791 } , [ params . teamId , teamId , dispatch , isLoggedIn ] ) ;
8892
93+ useEffect ( ( ) => {
94+ if ( isLoggedIn ) {
95+ dispatch ( authLoadV5UserProfile ( ) ) ;
96+ }
97+ } , [ dispatch , isLoggedIn ] ) ;
98+
8999 return (
90100 < >
91101 { /* Show loading indicator until we know if user is logged-in or no.
92102 Also, show loading indicator if we need to know team members but haven't loaded them yet.
103+ or load v5 user profile but haven't loaded them yet.
93104 In we got error during this process, show error */ }
94105 { isLoggedIn === null ||
95- ( params . teamId && ! teamMembersLoaded && (
96- < LoadingIndicator error = { authError || teamMembersLoadingError } />
106+ ( ( params . teamId && ! teamMembersLoaded || v5UserProfileLoading || v5UserProfileLoadingError ) && (
107+ < LoadingIndicator error = { authError || teamMembersLoadingError || v5UserProfileLoadingError } />
97108 ) ) }
98109
99110 { /* Show component only if user is logged-in and if we don't need team members or we already loaded them */ }
100- { isLoggedIn === true && ( ! params . teamId || teamMembersLoaded ) ? (
111+ { isLoggedIn === true &&
112+ v5UserProfile &&
113+ ( ! params . teamId || teamMembersLoaded ) ? (
101114 < Component { ...props } />
102115 ) : null }
103116 </ >
0 commit comments