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 @@ -13,6 +13,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 +42,7 @@ + {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} -