-
Notifications
You must be signed in to change notification settings - Fork 24
fix: issue #112 #262
fix: issue #112 #262
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ import { | |
authUserSuccess, | ||
authUserError, | ||
authLoadTeamMembers, | ||
authLoadUserProfile, | ||
authClearTeamMembers, | ||
} from "./actions"; | ||
import { decodeToken } from "tc-auth-lib"; | ||
|
@@ -34,6 +35,8 @@ export default function withAuthentication(Component) { | |
teamId, | ||
teamMembersLoaded, | ||
teamMembersLoadingError, | ||
v5UserProfile, | ||
v5UserProfileLoadingError, | ||
} = useSelector((state) => state.authUser); | ||
const params = useParams(); | ||
|
||
|
@@ -86,6 +89,12 @@ export default function withAuthentication(Component) { | |
} | ||
}, [params.teamId, teamId, dispatch, isLoggedIn]); | ||
|
||
useEffect(() => { | ||
if (isLoggedIn) { | ||
dispatch(authLoadUserProfile()); | ||
} | ||
}, [dispatch, isLoggedIn]); | ||
|
||
return ( | ||
<> | ||
{/* Show loading indicator until we know if user is logged-in or no. | ||
|
@@ -96,8 +105,14 @@ export default function withAuthentication(Component) { | |
<LoadingIndicator error={authError || teamMembersLoadingError} /> | ||
))} | ||
|
||
{/* Show component only if v5 user profile load error */} | ||
{isLoggedIn === true && v5UserProfileLoadingError && ( | ||
<LoadingIndicator error={"Error: Network Error"} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yoution sorry, I didn't mean to show error There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know how to repreduce the error case There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you may change endpoint to incorrect one, like below, it should cause some error during request, and it should be shown on the page return axios.get(`${config.API.V5}/taas-teams/meBROKEN`); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, looks good, this is what was needed |
||
)} | ||
{/* Show component only if user is logged-in and if we don't need team members or we already loaded them */} | ||
{isLoggedIn === true && (!params.teamId || teamMembersLoaded) ? ( | ||
{isLoggedIn === true && | ||
v5UserProfile && | ||
(!params.teamId || teamMembersLoaded) ? ( | ||
<Component {...props} /> | ||
) : null} | ||
</> | ||
|
Uh oh!
There was an error while loading. Please reload this page.