From d1f1d57b2dbf6063f5a96058a7b04ea00b769600 Mon Sep 17 00:00:00 2001 From: dadalmeida1 Date: Wed, 8 Mar 2023 11:05:01 +0100 Subject: [PATCH] fix auto log --- src/FLAD/navigation/AuthNavigation.tsx | 18 ++++++++++-------- src/FLAD/redux/reducers/userReducer.tsx | 6 ++++-- src/FLAD/redux/thunk/authThunk.tsx | 1 + 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/FLAD/navigation/AuthNavigation.tsx b/src/FLAD/navigation/AuthNavigation.tsx index daf8c95..6f171fc 100644 --- a/src/FLAD/navigation/AuthNavigation.tsx +++ b/src/FLAD/navigation/AuthNavigation.tsx @@ -23,25 +23,27 @@ export default function AuthNavigation() { useEffect(() => { async function prepare() { console.log(appIsReady, "1 AuthNav") - + //@ts-ignore await dispatch(getRefreshToken()) - await SplashScreen.hideAsync(); + if (appIsReady) { + console.log("++++++++++++++++++++++++++++++++++++++jsiuis con +++++++++++++++++++++++++++++3"); + await SplashScreen.hideAsync(); + } // await SplashScreen.hideAsync(); } prepare(); - }, [dispatch]); - - const onStackRootView = useCallback(async () => { - if (appIsReady) { - await SplashScreen.hideAsync(); - } }, [appIsReady]); + // const onStackRootView = useCallback(async () => { + + // }, [appIsReady]); + if (appIsReady == false) { console.log(appIsReady, "T9 AuthNav") return null; } console.log(appIsReady, "k9 AuthNav") + // console.log(userToken, "k9 AuthNav") return ( <> diff --git a/src/FLAD/redux/reducers/userReducer.tsx b/src/FLAD/redux/reducers/userReducer.tsx index 421f706..6dd6793 100644 --- a/src/FLAD/redux/reducers/userReducer.tsx +++ b/src/FLAD/redux/reducers/userReducer.tsx @@ -3,7 +3,7 @@ import { userTypes } from "../types/userTypes"; const initialState = { loading: false, user: User, // for user object - userFladToken: null, // for storing the JWT + userFladToken: "", // for storing the JWT userSpotifyToken : null, error: null, isLogedIn: false, @@ -14,11 +14,13 @@ const initialState = { // just for the navigation and speciafly use // and case userTypes.RESTORE_TOKEN: + const resp = (action.playload == "" ? false : true) + console.log(resp, "si il ya le tokennen ou passssssssssss") return { ...state, userFladToken : action.playload, loading: true, - // isLogedIn: true, + isLogedIn: resp, }; case userTypes.LOGIN: console.log("++++++++++++++++++++++++++++++++++++++userRducer+++++++++++++++++++++++++++++3"); diff --git a/src/FLAD/redux/thunk/authThunk.tsx b/src/FLAD/redux/thunk/authThunk.tsx index 631ad33..519aed5 100644 --- a/src/FLAD/redux/thunk/authThunk.tsx +++ b/src/FLAD/redux/thunk/authThunk.tsx @@ -114,6 +114,7 @@ export const getRefreshToken = () => { console.log("==========key2 =================="); console.log(userToken); console.log("==========key =================="); + console.log("==========on devrais ĂȘtre laaaa =================="); dispatch(restoreToken(userToken) );