From c0fb5245f1201ac424f6fb2f789510f94fa6d2fc Mon Sep 17 00:00:00 2001 From: Hailey Date: Fri, 15 Nov 2024 17:32:28 -0800 Subject: Tweak email verification dialog (#6397) --- src/components/dialogs/VerifyEmailDialog.tsx | 67 +++++++++++++++++++--------- src/lib/hooks/useEmail.ts | 16 ++++++- 2 files changed, 59 insertions(+), 24 deletions(-) (limited to 'src') 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({ ) : null} - - {currentStep === 'StepOne' ? ( - <> - {!reasonText ? ( - <> - - You'll receive an email at{' '} - - {currentAccount?.email} - {' '} - to verify it's you. - {' '} + {currentStep === 'StepOne' ? ( + + {reasonText ? ( + + {reasonText} + + Don't have access to{' '} + + {currentAccount?.email} + + ?{' '} - Need to change it? + Change your email address - - ) : ( - reasonText - )} - - ) : ( - uiStrings[currentStep].message - )} - + . + + + ) : ( + + + You'll receive an email at{' '} + + {currentAccount?.email} + {' '} + to verify it's you. + {' '} + { + e.preventDefault() + control.close(() => { + openModal({name: 'change-email'}) + }) + return false + }}> + Need to change it? + + + )} + + ) : ( + + {uiStrings[currentStep].message} + + )} {currentStep === 'StepTwo' ? ( 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} } -- cgit 1.4.1