diff --git a/src/state/modals/index.tsx b/src/state/modals/index.tsx index 1709f02882..45c4fb4678 100644 --- a/src/state/modals/index.tsx +++ b/src/state/modals/index.tsx @@ -55,16 +55,6 @@ export interface PostLanguagesSettingsModal { name: 'post-languages-settings' } -export interface VerifyEmailModal { - name: 'verify-email' - showReminder?: boolean - onSuccess?: () => void -} - -export interface ChangeEmailModal { - name: 'change-email' -} - export interface ChangePasswordModal { name: 'change-password' } @@ -84,8 +74,6 @@ export interface InAppBrowserConsentModal { export type Modal = // Account | DeleteAccountModal - | VerifyEmailModal - | ChangeEmailModal | ChangePasswordModal // Temp diff --git a/src/view/com/modals/ChangeEmail.tsx b/src/view/com/modals/ChangeEmail.tsx deleted file mode 100644 index 003d3630e6..0000000000 --- a/src/view/com/modals/ChangeEmail.tsx +++ /dev/null @@ -1,268 +0,0 @@ -import {useState} from 'react' -import {ActivityIndicator, SafeAreaView, StyleSheet, View} from 'react-native' -import {msg, Trans} from '@lingui/macro' -import {useLingui} from '@lingui/react' - -import {usePalette} from '#/lib/hooks/usePalette' -import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' -import {cleanError} from '#/lib/strings/errors' -import {colors, s} from '#/lib/styles' -import {isWeb} from '#/platform/detection' -import {useModalControls} from '#/state/modals' -import {useAgent, useSession} from '#/state/session' -import {ErrorMessage} from '../util/error/ErrorMessage' -import {Button} from '../util/forms/Button' -import {Text} from '../util/text/Text' -import * as Toast from '../util/Toast' -import {ScrollView, TextInput} from './util' - -enum Stages { - InputEmail, - ConfirmCode, - Done, -} - -export const snapPoints = ['90%'] - -export function Component() { - const pal = usePalette('default') - const {currentAccount} = useSession() - const agent = useAgent() - const {_} = useLingui() - const [stage, setStage] = useState(Stages.InputEmail) - const [email, setEmail] = useState(currentAccount?.email || '') - const [confirmationCode, setConfirmationCode] = useState('') - const [isProcessing, setIsProcessing] = useState(false) - const [error, setError] = useState('') - const {isMobile} = useWebMediaQueries() - const {openModal, closeModal} = useModalControls() - - const onRequestChange = async () => { - if (email === currentAccount?.email) { - setError(_(msg`Enter your new email above`)) - return - } - setError('') - setIsProcessing(true) - try { - const res = await agent.com.atproto.server.requestEmailUpdate() - if (res.data.tokenRequired) { - setStage(Stages.ConfirmCode) - } else { - await agent.com.atproto.server.updateEmail({email: email.trim()}) - await agent.resumeSession(agent.session!) - Toast.show(_(msg({message: 'Email updated', context: 'toast'}))) - setStage(Stages.Done) - } - } catch (e) { - let err = cleanError(String(e)) - // TEMP - // while rollout is occuring, we're giving a temporary error message - // you can remove this any time after Oct2023 - // -prf - if (err === 'email must be confirmed (temporary)') { - err = _( - msg`Please confirm your email before changing it. This is a temporary requirement while email-updating tools are added, and it will soon be removed.`, - ) - } - setError(err) - } finally { - setIsProcessing(false) - } - } - - const onConfirm = async () => { - setError('') - setIsProcessing(true) - try { - await agent.com.atproto.server.updateEmail({ - email: email.trim(), - token: confirmationCode.trim(), - }) - await agent.resumeSession(agent.session!) - Toast.show(_(msg({message: 'Email updated', context: 'toast'}))) - setStage(Stages.Done) - } catch (e) { - setError(cleanError(String(e))) - } finally { - setIsProcessing(false) - } - } - - const onVerify = async () => { - closeModal() - openModal({name: 'verify-email'}) - } - - return ( - - - - - {stage === Stages.InputEmail ? _(msg`Change Your Email`) : ''} - {stage === Stages.ConfirmCode ? _(msg`Security Step Required`) : ''} - {stage === Stages.Done ? _(msg`Email Updated`) : ''} - - - - - {stage === Stages.InputEmail ? ( - Enter your new email address below. - ) : stage === Stages.ConfirmCode ? ( - - An email has been sent to your previous address,{' '} - {currentAccount?.email || '(no email)'}. It includes a - confirmation code which you can enter below. - - ) : ( - - Your email has been updated but not verified. As a next step, - please verify your new email. - - )} - - - {stage === Stages.InputEmail && ( - - )} - {stage === Stages.ConfirmCode && ( - - )} - - {error ? ( - - ) : undefined} - - - {isProcessing ? ( - - - - ) : ( - - {stage === Stages.InputEmail && ( -