Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3406256
D7959.id27001.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
D7959.id27001.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
@@ -37,6 +37,7 @@
import { initOpaque } from './crypto/opaque-utils.js';
import electron from './electron.js';
import InputStateContainer from './input/input-state-container.react.js';
+import InviteLinkHandler from './invite-links/invite-link-handler.react.js';
import LoadingIndicator from './loading-indicator.react.js';
import { MenuProvider } from './menu-provider.react.js';
import UpdateModalHandler from './modals/update-modal.react.js';
@@ -169,6 +170,7 @@
<DeviceIDUpdater />
<PolicyAcknowledgmentHandler />
<PushNotificationsHandler />
+ <InviteLinkHandler />
{content}
{this.props.modals}
</WagmiENSCacheProvider>
diff --git a/web/invite-links/invite-link-handler.react.js b/web/invite-links/invite-link-handler.react.js
new file mode 100644
--- /dev/null
+++ b/web/invite-links/invite-link-handler.react.js
@@ -0,0 +1,63 @@
+// @flow
+
+import * as React from 'react';
+import { useDispatch } from 'react-redux';
+
+import {
+ verifyInviteLink,
+ verifyInviteLinkActionTypes,
+} from 'lib/actions/link-actions.js';
+import { useModalContext } from 'lib/components/modal-provider.react.js';
+import { isLoggedIn } from 'lib/selectors/user-selectors.js';
+import {
+ useDispatchActionPromise,
+ useServerCall,
+} from 'lib/utils/action-utils.js';
+
+import AcceptInviteModal from './accept-invite-modal.react.js';
+import { updateNavInfoActionType } from '../redux/action-types.js';
+import { useSelector } from '../redux/redux-utils.js';
+
+function InviteLinkHandler(): null {
+ const inviteSecret = useSelector(state => state.navInfo.inviteSecret);
+ const loggedIn = useSelector(isLoggedIn);
+
+ const dispatchActionPromise = useDispatchActionPromise();
+ const dispatch = useDispatch();
+ const validateLink = useServerCall(verifyInviteLink);
+ const { pushModal } = useModalContext();
+ React.useEffect(() => {
+ if (!inviteSecret || !loggedIn) {
+ return;
+ }
+ dispatch({
+ type: updateNavInfoActionType,
+ payload: { inviteSecret: null },
+ });
+ const validateLinkPromise = validateLink({ secret: inviteSecret });
+ dispatchActionPromise(verifyInviteLinkActionTypes, validateLinkPromise);
+ (async () => {
+ const result = await validateLinkPromise;
+ if (result.status === 'already_joined') {
+ return;
+ }
+ pushModal(
+ <AcceptInviteModal
+ verificationResponse={result}
+ inviteSecret={inviteSecret}
+ />,
+ );
+ })();
+ }, [
+ dispatch,
+ dispatchActionPromise,
+ inviteSecret,
+ loggedIn,
+ pushModal,
+ validateLink,
+ ]);
+
+ return null;
+}
+
+export default InviteLinkHandler;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 5, 1:15 AM (13 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2615404
Default Alt Text
D7959.id27001.diff (2 KB)
Attached To
Mode
D7959: [web] Open invite link modal when the link is clicked
Attached
Detach File
Event Timeline
Log In to Comment