diff --git a/src/config/routes.js b/src/config/routes.js index 662b0628e..308ffc926 100644 --- a/src/config/routes.js +++ b/src/config/routes.js @@ -30,6 +30,6 @@ export default SwitchNavigator({ [ROUTES.SCREENS.EDITOR]: { screen: RootComponent()(Editor) }, [ROUTES.SCREENS.PINCODE]: { screen: RootComponent()(PinCode) }, [ROUTES.SCREENS.PROFILE]: { screen: RootComponent()(Profile) }, - [ROUTES.SCREENS.SPLASH]: { screen: RootComponent()(Splash) }, + [ROUTES.SCREENS.SPLASH]: { screen: Splash }, [ROUTES.SCREENS.STEEM_CONNECT]: { screen: RootComponent()(SteemConnect) }, }); diff --git a/src/redux/actions/applicationActions.js b/src/redux/actions/applicationActions.js index 134080c6c..32d6a5db6 100644 --- a/src/redux/actions/applicationActions.js +++ b/src/redux/actions/applicationActions.js @@ -1,5 +1,9 @@ import { - LOGIN, LOGOUT, OPEN_PIN_CODE_MODAL, CLOSE_PIN_CODE_MODAL, + LOGIN, + LOGOUT, + OPEN_PIN_CODE_MODAL, + CLOSE_PIN_CODE_MODAL, + ACTIVE_APPLICATION, } from '../constants/constants'; export const login = () => ({ @@ -17,3 +21,7 @@ export const openPinCodeModal = () => ({ export const closePinCodeModal = () => ({ type: CLOSE_PIN_CODE_MODAL, }); + +export const activeApplication = () => ({ + type: ACTIVE_APPLICATION, +}); diff --git a/src/redux/constants/constants.js b/src/redux/constants/constants.js index b7b31444a..0ba473642 100644 --- a/src/redux/constants/constants.js +++ b/src/redux/constants/constants.js @@ -17,3 +17,4 @@ export const FETCH_ACCOUNT_FAIL = 'FETCH_ACCOUNT_FAIL'; export const IS_LOGGED_IN = 'IS_LOGGED_IN'; export const OPEN_PIN_CODE_MODAL = 'OPEN_PIN_CODE_MODAL'; export const CLOSE_PIN_CODE_MODAL = 'CLOSE_PIN_CODE_MODAL'; +export const ACTIVE_APPLICATION = 'ACTIVE_APPLICATION'; diff --git a/src/redux/reducers/applicationReducer.js b/src/redux/reducers/applicationReducer.js index d204fe1a6..7d11e0e79 100644 --- a/src/redux/reducers/applicationReducer.js +++ b/src/redux/reducers/applicationReducer.js @@ -1,11 +1,16 @@ import { - LOGIN, LOGOUT, OPEN_PIN_CODE_MODAL, CLOSE_PIN_CODE_MODAL, + LOGIN, + LOGOUT, + OPEN_PIN_CODE_MODAL, + CLOSE_PIN_CODE_MODAL, + ACTIVE_APPLICATION, } from '../constants/constants'; const initialState = { isLoggedIn: false, // Has any logged in user. loading: false, // It is lock to all screen and shows loading animation. isPinCodeReqiure: false, + isActive: false, }; export default function (state = initialState, action) { @@ -30,6 +35,11 @@ export default function (state = initialState, action) { ...state, isPinCodeReqiure: false, }; + case ACTIVE_APPLICATION: + return { + ...state, + isActive: true, + }; default: return state; } diff --git a/src/screens/root/container/rootContainer.js b/src/screens/root/container/rootContainer.js index 084ac56cf..098b85797 100644 --- a/src/screens/root/container/rootContainer.js +++ b/src/screens/root/container/rootContainer.js @@ -9,6 +9,9 @@ import { openPinCodeModal } from '../../../redux/actions/applicationActions'; import { Modal } from '../../../components'; import { PinCode } from '../..'; +// Constants +import { default as ROUTES } from '../../../constants/routeNames'; + const RootContainer = () => (WrappedComponent) => { class RootComponent extends Component { constructor(props) { @@ -20,6 +23,13 @@ const RootContainer = () => (WrappedComponent) => { }; } + componentWillMount() { + const { isActive, navigation } = this.props; + if (!isActive) { + navigation.navigate(ROUTES.SCREENS.SPLASH); + } + } + componentDidMount() { AppState.addEventListener('change', this._handleAppStateChange); } @@ -74,6 +84,7 @@ const RootContainer = () => (WrappedComponent) => { } const mapStateToProps = state => ({ isPinCodeReqiure: state.application.isPinCodeReqiure, + isActiveApp: state.application.isActive, }); return connect(mapStateToProps)(RootComponent); diff --git a/src/screens/splash/container/splashContainer.js b/src/screens/splash/container/splashContainer.js index d1a6a3dab..091e2c658 100644 --- a/src/screens/splash/container/splashContainer.js +++ b/src/screens/splash/container/splashContainer.js @@ -14,15 +14,18 @@ class SplashContainer extends Component { _getUserData = () => { const { navigation } = this.props; - + getAuthStatus().then((res) => { + console.log('=========res=========', res); + getUserData().then((response) => { - if (response) { - navigation.navigate(ROUTES.SCREENS.PINCODE); - // navigation.navigate(ROUTES.DRAWER.MAIN); - } else { - navigation.navigate(ROUTES.SCREENS.LOGIN); - } + console.log('=========response=========', response); + // if (response) { + // navigation.navigate(ROUTES.SCREENS.PINCODE); + // // navigation.navigate(ROUTES.DRAWER.MAIN); + // } else { + // navigation.navigate(ROUTES.SCREENS.LOGIN); + // } }); }); };