Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 1e8ef72

Browse files
committed
fix: load v5 profile only once
1 parent e6c933e commit 1e8ef72

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/hoc/withAuthentication/index.js

+16-6
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,32 @@ export default function withAuthentication(Component) {
9090
}
9191
}, [params.teamId, teamId, dispatch, isLoggedIn]);
9292

93+
/*
94+
Load V5 User Profile
95+
*/
9396
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) {
9599
dispatch(authLoadV5UserProfile());
96100
}
97-
}, [dispatch, isLoggedIn]);
101+
}, [dispatch, isLoggedIn, v5UserProfileLoading, v5UserProfile]);
98102

99103
return (
100104
<>
101105
{/* Show loading indicator until we know if user is logged-in or no.
102106
Also, show loading indicator if we need to know team members but haven't loaded them yet.
103107
or load v5 user profile but haven't loaded them yet.
104108
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+
)}
109119

110120
{/* Show component only if user is logged-in and if we don't need team members or we already loaded them */}
111121
{isLoggedIn === true &&

0 commit comments

Comments
 (0)