made loading profile to load only when user login status is false

This commit was merged in pull request #35.
This commit is contained in:
victorAnumudu
2023-05-02 09:02:09 +01:00
parent 6ce51b5a7e
commit adca9029ae
+4 -1
View File
@@ -34,6 +34,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
window.addEventListener('keydown', resetTime)
const loadProfile = ()=>{ // function to load user profile
setIsLogin({loading: true, status: false})
apiCall.loadProfile().then((res)=>{
if(res.data.internal_return < 0){
setIsLogin({loading: false, status: false})
@@ -50,7 +51,9 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
}, [])
useEffect(() => {
getProfile()
if(!isLogin.status){
getProfile()
}
const checkInactivity = setInterval(() => {
if (Date.now() - lastActivityTime > process.env.REACT_APP_SESSION_EXPIRE_MINUTES) {