Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3490350
D5830.id19379.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
D5830.id19379.diff
View Options
diff --git a/web/app.react.js b/web/app.react.js
--- a/web/app.react.js
+++ b/web/app.react.js
@@ -42,6 +42,7 @@
import DisconnectedBar from './redux/disconnected-bar';
import DisconnectedBarVisibilityHandler from './redux/disconnected-bar-visibility-handler';
import FocusHandler from './redux/focus-handler.react';
+import PolicyAcknowledgmentHandler from './redux/policy-acknowledgment-handler.js';
import { useSelector } from './redux/redux-utils';
import VisibilityHandler from './redux/visibility-handler.react';
import history from './router-history';
@@ -155,6 +156,7 @@
<FocusHandler />
<VisibilityHandler />
<DeviceIDUpdater />
+ <PolicyAcknowledgmentHandler />
{content}
{this.props.modals}
</MenuProvider>
diff --git a/web/modals/terms-and-privacy-modal.react.js b/web/modals/terms-and-privacy-modal.react.js
--- a/web/modals/terms-and-privacy-modal.react.js
+++ b/web/modals/terms-and-privacy-modal.react.js
@@ -59,7 +59,7 @@
<div className={css.container}>
We recently updated our{' '}
<a
- href="https://comm.app/privacy"
+ href="https://comm.app/terms"
target="_blank"
rel="noreferrer"
className={css.link}
@@ -68,7 +68,7 @@
</a>
{' & '}
<a
- href="https://comm.app/terms"
+ href="https://comm.app/privacy"
target="_blank"
rel="noreferrer"
className={css.link}
diff --git a/web/redux/policy-acknowledgment-handler.js b/web/redux/policy-acknowledgment-handler.js
new file mode 100644
--- /dev/null
+++ b/web/redux/policy-acknowledgment-handler.js
@@ -0,0 +1,41 @@
+// @flow
+
+import * as React from 'react';
+
+import { useModalContext } from 'lib/components/modal-provider.react.js';
+import { policyTypes } from 'lib/facts/policies.js';
+
+import TermsAndPrivacyModal from '../modals/terms-and-privacy-modal.react.js';
+import { useSelector } from './redux-utils.js';
+
+function PolicyAcknowledgmentHandler(): null {
+ const termsAndPrivacyState = useSelector(
+ state => state.userPolicies?.[policyTypes.tosAndPrivacyPolicy],
+ );
+ const [policyModalKey, setPolicyModalKey] = React.useState(null);
+ const { pushModal, popModal, modals } = useModalContext();
+
+ const policyModalVisible = React.useMemo(
+ () => modals.some(modalEntry => modalEntry[1] === policyModalKey),
+ [modals, policyModalKey],
+ );
+
+ React.useEffect(() => {
+ if (!termsAndPrivacyState) {
+ return;
+ }
+
+ const { isAcknowledged } = termsAndPrivacyState;
+ if (!isAcknowledged && !policyModalVisible) {
+ const modalKey = pushModal(<TermsAndPrivacyModal />);
+ setPolicyModalKey(modalKey);
+ }
+ if (isAcknowledged && policyModalVisible) {
+ popModal();
+ }
+ }, [policyModalVisible, popModal, pushModal, termsAndPrivacyState]);
+
+ return null;
+}
+
+export default PolicyAcknowledgmentHandler;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 3:56 PM (20 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2677899
Default Alt Text
D5830.id19379.diff (2 KB)
Attached To
Mode
D5830: [web] policy acknowledgment handler
Attached
Detach File
Event Timeline
Log In to Comment