From 1ebcf5b5fb928bddc5011443762117d7d893b6ee Mon Sep 17 00:00:00 2001
From: Yoan VALLET <ext.sopra.yvallet@grandlyon.com>
Date: Wed, 27 May 2020 23:29:05 +0200
Subject: [PATCH] feat: track loding success for userprofile on init

---
 src/components/Contexts/AppContextProvider.tsx | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/components/Contexts/AppContextProvider.tsx b/src/components/Contexts/AppContextProvider.tsx
index dfc788f47..1a2e767f2 100644
--- a/src/components/Contexts/AppContextProvider.tsx
+++ b/src/components/Contexts/AppContextProvider.tsx
@@ -94,6 +94,10 @@ const AppContextProvider: React.FC<AppContextProviderProps> = ({
   const [isContextLoaded, setContextLoaded] = useState<boolean>(false)
   const [isError, setError] = useState<boolean>(false)
   const [screenType, setScreenType] = useState<ScreenType>(ScreenType.MOBILE)
+
+  const [isUserProfileLoadingSuccess, setUserProfileLoadingSuccess] = useState<
+    boolean | null
+  >(null)
   const [userProfile, setUserProfile] = useState<UserProfile | null>(null)
 
   const defineScreenType = () => {
@@ -250,6 +254,7 @@ const AppContextProvider: React.FC<AppContextProviderProps> = ({
           'background: #222; color: white'
         )
         setUserProfile(loadedUserProfile)
+        setUserProfileLoadingSuccess(true)
       }
     }
     loadData()
@@ -265,6 +270,7 @@ const AppContextProvider: React.FC<AppContextProviderProps> = ({
       isDataLoadingSuccess &&
       isFluidTypesLoadingSuccess &&
       isCurrentChallengeUpdateLoadingSuccess &&
+      isUserProfileLoadingSuccess &&
       !isError
     ) {
       setTimeout(function() {
@@ -276,6 +282,7 @@ const AppContextProvider: React.FC<AppContextProviderProps> = ({
     isDataLoadingSuccess,
     isFluidTypesLoadingSuccess,
     isCurrentChallengeUpdateLoadingSuccess,
+    isUserProfileLoadingSuccess,
     isError,
   ])
 
-- 
GitLab