diff --git a/native/navigation/navigation-handler.react.js b/native/navigation/navigation-handler.react.js --- a/native/navigation/navigation-handler.react.js +++ b/native/navigation/navigation-handler.react.js @@ -1,10 +1,12 @@ // @flow import * as React from 'react'; +import { PersistGate } from 'redux-persist/integration/react'; import { isLoggedIn } from 'lib/selectors/user-selectors'; import DevTools from '../redux/dev-tools.react'; +import { getPersistor } from '../redux/persist'; import { useSelector } from '../redux/redux-utils'; import type { AppState } from '../redux/state-types'; import { usePersistedStateLoaded } from '../selectors/app-state-selectors'; @@ -13,6 +15,7 @@ import NavFromReduxHandler from './nav-from-redux-handler.react'; import { useIsAppLoggedIn } from './nav-selectors'; import { NavContext, type NavAction } from './navigation-context'; +import PolicyAcknowledgmentHandler from './policy-acknowledgment-handler.react'; import ThreadScreenTracker from './thread-screen-tracker.react'; const NavigationHandler: React.ComponentType<{}> = React.memo<{}>( @@ -41,6 +44,9 @@ + + + {devTools} ); diff --git a/native/navigation/policy-acknowledgment-handler.react.js b/native/navigation/policy-acknowledgment-handler.react.js new file mode 100644 --- /dev/null +++ b/native/navigation/policy-acknowledgment-handler.react.js @@ -0,0 +1,28 @@ +// @flow + +import { useNavigation } from '@react-navigation/native'; +import * as React from 'react'; + +import { policyTypes } from 'lib/facts/policies'; + +import { useSelector } from '../redux/redux-utils'; +import { TermsAndPrivacyRouteName } from './route-names'; + +function PolicyAcknowledgmentHandler(): null { + const userPolicies = useSelector(state => state.userPolicies); + const navigation = useNavigation(); + + React.useEffect(() => { + const tosAndPrivacyState = userPolicies?.[policyTypes.tosAndPrivacyPolicy]; + if (tosAndPrivacyState && !tosAndPrivacyState?.isAcknowledged) { + navigation.navigate<'TermsAndPrivacyModal'>({ + name: TermsAndPrivacyRouteName, + params: { policyType: policyTypes.tosAndPrivacyPolicy }, + }); + } + }, [navigation, userPolicies]); + + return null; +} + +export default PolicyAcknowledgmentHandler; diff --git a/native/root.react.js b/native/root.react.js --- a/native/root.react.js +++ b/native/root.react.js @@ -236,6 +236,7 @@ ref={containerRef} > + ); } @@ -262,7 +263,6 @@ /> {navigation} -