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

[PROD] Patch 1.7.0.1 #270

Merged
merged 5 commits into from
May 25, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: load v5 profile only once
  • Loading branch information
maxceem committed May 18, 2021
commit 1e8ef7297d41f94eb19c8aa7ed7298c1309e107e
22 changes: 16 additions & 6 deletions src/hoc/withAuthentication/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,32 @@ export default function withAuthentication(Component) {
}
}, [params.teamId, teamId, dispatch, isLoggedIn]);

/*
Load V5 User Profile
*/
useEffect(() => {
if (isLoggedIn) {
// is user is logged-in, but V5 user profile is not loaded yet, then load it
if (isLoggedIn && !v5UserProfileLoading && !v5UserProfile) {
dispatch(authLoadV5UserProfile());
}
}, [dispatch, isLoggedIn]);
}, [dispatch, isLoggedIn, v5UserProfileLoading, v5UserProfile]);

return (
<>
{/* Show loading indicator until we know if user is logged-in or no.
Also, show loading indicator if we need to know team members but haven't loaded them yet.
or load v5 user profile but haven't loaded them yet.
In we got error during this process, show error */}
{isLoggedIn === null ||
((params.teamId && !teamMembersLoaded || v5UserProfileLoading || v5UserProfileLoadingError)&& (
<LoadingIndicator error={authError || teamMembersLoadingError || v5UserProfileLoadingError} />
))}
{(isLoggedIn === null ||
(params.teamId && !teamMembersLoaded) ||
v5UserProfileLoading ||
v5UserProfileLoadingError) && (
<LoadingIndicator
error={
authError || teamMembersLoadingError || v5UserProfileLoadingError
}
/>
)}

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