Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3490714
D5832.id19255.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D5832.id19255.diff
View Options
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
@@ -15,7 +15,10 @@
initialWindowMetrics,
} from 'react-native-safe-area-context';
import { Provider } from 'react-redux';
-import { PersistGate as ReduxPersistGate } from 'redux-persist/integration/react';
+import {
+ PersistGate,
+ PersistGate as ReduxPersistGate,
+} from 'redux-persist/integration/react';
import { actionLogger } from 'lib/utils/action-logger';
@@ -35,6 +38,7 @@
import { validNavState } from './navigation/navigation-utils';
import OrientationHandler from './navigation/orientation-handler.react';
import { navStateAsyncStorageKey } from './navigation/persistance';
+import PolicyAcknowledgmentHandler from './navigation/policy-acknowledgment-handler.react';
import RootNavigator from './navigation/root-navigator.react';
import ConnectivityUpdater from './redux/connectivity-updater.react';
import { DimensionsUpdater } from './redux/dimensions-updater.react';
@@ -236,6 +240,9 @@
ref={containerRef}
>
<RootNavigator />
+ <PersistGate persistor={getPersistor()}>
+ <PolicyAcknowledgmentHandler />
+ </PersistGate>
</NavigationContainer>
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 5:14 PM (20 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2678113
Default Alt Text
D5832.id19255.diff (2 KB)
Attached To
Mode
D5832: [native] policy acknowledgment handler
Attached
Detach File
Event Timeline
Log In to Comment