diff options
-rw-r--r-- | src/components/dialogs/VerifyEmailDialog.tsx | 67 | ||||
-rw-r--r-- | src/lib/hooks/useEmail.ts | 16 |
2 files changed, 59 insertions, 24 deletions
diff --git a/src/components/dialogs/VerifyEmailDialog.tsx b/src/components/dialogs/VerifyEmailDialog.tsx index d4412b6f8..ced9171ce 100644 --- a/src/components/dialogs/VerifyEmailDialog.tsx +++ b/src/components/dialogs/VerifyEmailDialog.tsx @@ -146,18 +146,17 @@ export function Inner({ <ErrorMessage message={error} /> </View> ) : null} - <Text style={[a.text_md, a.leading_snug]}> - {currentStep === 'StepOne' ? ( - <> - {!reasonText ? ( - <> - <Trans> - You'll receive an email at{' '} - <Text style={[a.text_md, a.leading_snug, a.font_bold]}> - {currentAccount?.email} - </Text>{' '} - to verify it's you. - </Trans>{' '} + {currentStep === 'StepOne' ? ( + <View> + {reasonText ? ( + <View style={[a.gap_sm]}> + <Text style={[a.text_md, a.leading_snug]}>{reasonText}</Text> + <Text style={[a.text_md, a.leading_snug]}> + Don't have access to{' '} + <Text style={[a.text_md, a.leading_snug, a.font_bold]}> + {currentAccount?.email} + </Text> + ?{' '} <InlineLinkText to="#" label={_(msg`Change email address`)} @@ -169,17 +168,41 @@ export function Inner({ }) return false }}> - <Trans>Need to change it?</Trans> + <Trans>Change your email address</Trans> </InlineLinkText> - </> - ) : ( - reasonText - )} - </> - ) : ( - uiStrings[currentStep].message - )} - </Text> + . + </Text> + </View> + ) : ( + <Text style={[a.text_md, a.leading_snug]}> + <Trans> + You'll receive an email at{' '} + <Text style={[a.text_md, a.leading_snug, a.font_bold]}> + {currentAccount?.email} + </Text>{' '} + to verify it's you. + </Trans>{' '} + <InlineLinkText + to="#" + label={_(msg`Change email address`)} + style={[a.text_md, a.leading_snug]} + onPress={e => { + e.preventDefault() + control.close(() => { + openModal({name: 'change-email'}) + }) + return false + }}> + <Trans>Need to change it?</Trans> + </InlineLinkText> + </Text> + )} + </View> + ) : ( + <Text style={[a.text_md, a.leading_snug]}> + {uiStrings[currentStep].message} + </Text> + )} </View> {currentStep === 'StepTwo' ? ( <View> diff --git a/src/lib/hooks/useEmail.ts b/src/lib/hooks/useEmail.ts index 6e52846d1..ab87f057e 100644 --- a/src/lib/hooks/useEmail.ts +++ b/src/lib/hooks/useEmail.ts @@ -1,4 +1,5 @@ import {useServiceConfigQuery} from '#/state/queries/email-verification-required' +import {useProfileQuery} from '#/state/queries/profile' import {useSession} from '#/state/session' import {BSKY_SERVICE} from '../constants' import {getHostnameFromUrl} from '../strings/url-helpers' @@ -7,13 +8,24 @@ export function useEmail() { const {currentAccount} = useSession() const {data: serviceConfig} = useServiceConfigQuery() + const {data: profile} = useProfileQuery({did: currentAccount?.did}) + + const checkEmailConfirmed = !!serviceConfig?.checkEmailConfirmed + + const isNewEnough = + !!profile?.createdAt && + Date.parse(profile.createdAt) >= Date.parse('2024-11-16T02:00:00.000Z') const isSelfHost = - serviceConfig?.checkEmailConfirmed && currentAccount && getHostnameFromUrl(currentAccount.service) !== getHostnameFromUrl(BSKY_SERVICE) - const needsEmailVerification = !isSelfHost && !currentAccount?.emailConfirmed + + const needsEmailVerification = + !isSelfHost && + checkEmailConfirmed && + !!currentAccount?.emailConfirmed && + isNewEnough return {needsEmailVerification} } |