diff options
Diffstat (limited to 'src/lib/hooks/useIntentHandler.ts')
-rw-r--r-- | src/lib/hooks/useIntentHandler.ts | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/lib/hooks/useIntentHandler.ts b/src/lib/hooks/useIntentHandler.ts index 460df3753..8cccda48f 100644 --- a/src/lib/hooks/useIntentHandler.ts +++ b/src/lib/hooks/useIntentHandler.ts @@ -6,15 +6,17 @@ import {isNative} from 'platform/detection' import {useSession} from 'state/session' import {useComposerControls} from 'state/shell' import {useCloseAllActiveElements} from 'state/util' +import {useIntentDialogs} from '#/components/intents/IntentDialogs' import {Referrer} from '../../../modules/expo-bluesky-swiss-army' -type IntentType = 'compose' +type IntentType = 'compose' | 'verify-email' const VALID_IMAGE_REGEX = /^[\w.:\-_/]+\|\d+(\.\d+)?\|\d+(\.\d+)?$/ export function useIntentHandler() { const incomingUrl = Linking.useURL() const composeIntent = useComposeIntent() + const verifyEmailIntent = useVerifyEmailIntent() React.useEffect(() => { const handleIncomingURL = (url: string) => { @@ -51,12 +53,22 @@ export function useIntentHandler() { text: params.get('text'), imageUrisStr: params.get('imageUris'), }) + return + } + case 'verify-email': { + const code = params.get('code') + if (!code) return + verifyEmailIntent(code) + return + } + default: { + return } } } if (incomingUrl) handleIncomingURL(incomingUrl) - }, [incomingUrl, composeIntent]) + }, [incomingUrl, composeIntent, verifyEmailIntent]) } function useComposeIntent() { @@ -103,3 +115,21 @@ function useComposeIntent() { [hasSession, closeAllActiveElements, openComposer], ) } + +function useVerifyEmailIntent() { + const closeAllActiveElements = useCloseAllActiveElements() + const {verifyEmailDialogControl: control, setVerifyEmailState: setState} = + useIntentDialogs() + return React.useCallback( + (code: string) => { + closeAllActiveElements() + setState({ + code, + }) + setTimeout(() => { + control.open() + }, 1000) + }, + [closeAllActiveElements, control, setState], + ) +} |