From 0d775997b360af64f74741dd9e5ba07eea33a1cc Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Tue, 23 Sep 2025 21:32:36 +0300 Subject: [PATCH] delete delete account modal --- src/state/modals/index.tsx | 7 - src/view/com/modals/DeleteAccount.tsx | 342 -------------------------- src/view/com/modals/Modal.tsx | 4 - src/view/com/modals/Modal.web.tsx | 3 - 4 files changed, 356 deletions(-) delete mode 100644 src/view/com/modals/DeleteAccount.tsx diff --git a/src/state/modals/index.tsx b/src/state/modals/index.tsx index dab90c0af3..5f023e0680 100644 --- a/src/state/modals/index.tsx +++ b/src/state/modals/index.tsx @@ -11,10 +11,6 @@ export interface UserAddRemoveListsModal { onRemove?: (listUri: string) => void } -export interface DeleteAccountModal { - name: 'delete-account' -} - export interface ContentLanguagesSettingsModal { name: 'content-languages-settings' } @@ -23,9 +19,6 @@ export interface ContentLanguagesSettingsModal { * @deprecated DO NOT ADD NEW MODALS */ export type Modal = - // Account - | DeleteAccountModal - // Curation | ContentLanguagesSettingsModal diff --git a/src/view/com/modals/DeleteAccount.tsx b/src/view/com/modals/DeleteAccount.tsx deleted file mode 100644 index 80ff157681..0000000000 --- a/src/view/com/modals/DeleteAccount.tsx +++ /dev/null @@ -1,342 +0,0 @@ -import React from 'react' -import { - ActivityIndicator, - SafeAreaView, - StyleSheet, - TouchableOpacity, - View, -} from 'react-native' -import {LinearGradient} from 'expo-linear-gradient' -import {msg, Trans} from '@lingui/macro' -import {useLingui} from '@lingui/react' - -import {DM_SERVICE_HEADERS} from '#/lib/constants' -import {usePalette} from '#/lib/hooks/usePalette' -import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' -import {cleanError} from '#/lib/strings/errors' -import {colors, gradients, s} from '#/lib/styles' -import {useTheme} from '#/lib/ThemeContext' -import {isAndroid, isWeb} from '#/platform/detection' -import {useModalControls} from '#/state/modals' -import {useAgent, useSession, useSessionApi} from '#/state/session' -import {atoms as a, useTheme as useNewTheme} from '#/alf' -import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo' -import {Text as NewText} from '#/components/Typography' -import {resetToTab} from '../../../Navigation' -import {ErrorMessage} from '../util/error/ErrorMessage' -import {Text} from '../util/text/Text' -import * as Toast from '../util/Toast' -import {ScrollView, TextInput} from './util' - -export const snapPoints = isAndroid ? ['90%'] : ['55%'] - -export function Component({}: {}) { - const pal = usePalette('default') - const theme = useTheme() - const t = useNewTheme() - const {currentAccount} = useSession() - const agent = useAgent() - const {removeAccount} = useSessionApi() - const {_} = useLingui() - const {closeModal} = useModalControls() - const {isMobile} = useWebMediaQueries() - const [isEmailSent, setIsEmailSent] = React.useState(false) - const [confirmCode, setConfirmCode] = React.useState('') - const [password, setPassword] = React.useState('') - const [isProcessing, setIsProcessing] = React.useState(false) - const [error, setError] = React.useState('') - const onPressSendEmail = async () => { - setError('') - setIsProcessing(true) - try { - await agent.com.atproto.server.requestAccountDelete() - setIsEmailSent(true) - } catch (e: any) { - setError(cleanError(e)) - } - setIsProcessing(false) - } - const onPressConfirmDelete = async () => { - if (!currentAccount?.did) { - throw new Error(`DeleteAccount modal: currentAccount.did is undefined`) - } - - setError('') - setIsProcessing(true) - const token = confirmCode.replace(/\s/g, '') - - try { - // inform chat service of intent to delete account - const {success} = await agent.api.chat.bsky.actor.deleteAccount( - undefined, - { - headers: DM_SERVICE_HEADERS, - }, - ) - if (!success) { - throw new Error('Failed to inform chat service of account deletion') - } - await agent.com.atproto.server.deleteAccount({ - did: currentAccount.did, - password, - token, - }) - Toast.show(_(msg`Your account has been deleted`)) - resetToTab('HomeTab') - removeAccount(currentAccount) - closeModal() - } catch (e: any) { - setError(cleanError(e)) - } - setIsProcessing(false) - } - const onCancel = () => { - closeModal() - } - return ( - - - - - - Delete Account{' '} - - " - - - {currentAccount?.handle} - - - " - - - - - {!isEmailSent ? ( - <> - - - For security reasons, we'll need to send a confirmation code to - your email address. - - - {error ? ( - - - - ) : undefined} - {isProcessing ? ( - - - - ) : ( - <> - - - - Send Email - - - - - - Cancel - - - - )} - - - - - - - - You can also temporarily deactivate your account instead, - and reactivate it at any time. - - - - - - ) : ( - <> - {/* TODO: Update this label to be more concise */} - - - Check your inbox for an email with the confirmation code to - enter below: - - - - - Please enter your password as well: - - - {error ? ( - - - - ) : undefined} - {isProcessing ? ( - - - - ) : ( - <> - - - Delete my account - - - - - Cancel - - - - )} - - )} - - - ) -} - -const styles = StyleSheet.create({ - titleContainer: { - display: 'flex', - flexDirection: 'row', - justifyContent: 'center', - flexWrap: 'wrap', - marginTop: 12, - marginBottom: 12, - marginLeft: 20, - marginRight: 20, - }, - titleMobile: { - textAlign: 'center', - }, - titleDesktop: { - textAlign: 'center', - overflow: 'hidden', - whiteSpace: 'nowrap', - textOverflow: 'ellipsis', - // @ts-ignore only rendered on web - maxWidth: '400px', - }, - description: { - textAlign: 'center', - paddingHorizontal: 22, - marginBottom: 10, - }, - mt20: { - marginTop: 20, - }, - mb20: { - marginBottom: 20, - }, - textInput: { - borderWidth: 1, - borderRadius: 6, - paddingHorizontal: 16, - paddingVertical: 12, - fontSize: 20, - marginHorizontal: 20, - }, - btn: { - flexDirection: 'row', - alignItems: 'center', - justifyContent: 'center', - borderRadius: 32, - padding: 14, - marginHorizontal: 20, - }, - evilBtn: { - backgroundColor: colors.red4, - }, -}) diff --git a/src/view/com/modals/Modal.tsx b/src/view/com/modals/Modal.tsx index 4ebec459dd..a4ace3629f 100644 --- a/src/view/com/modals/Modal.tsx +++ b/src/view/com/modals/Modal.tsx @@ -7,7 +7,6 @@ import {usePalette} from '#/lib/hooks/usePalette' import {useModalControls, useModals} from '#/state/modals' import {FullWindowOverlay} from '#/components/FullWindowOverlay' import {createCustomBackdrop} from '../util/BottomSheetCustomBackdrop' -import * as DeleteAccountModal from './DeleteAccount' import * as ContentLanguagesSettingsModal from './lang-settings/ContentLanguagesSettings' import * as UserAddRemoveListsModal from './UserAddRemoveLists' @@ -45,9 +44,6 @@ export function ModalsContainer() { if (activeModal?.name === 'user-add-remove-lists') { snapPoints = UserAddRemoveListsModal.snapPoints element = - } else if (activeModal?.name === 'delete-account') { - snapPoints = DeleteAccountModal.snapPoints - element = } else if (activeModal?.name === 'content-languages-settings') { snapPoints = ContentLanguagesSettingsModal.snapPoints element = diff --git a/src/view/com/modals/Modal.web.tsx b/src/view/com/modals/Modal.web.tsx index bdf8269925..cb932f4530 100644 --- a/src/view/com/modals/Modal.web.tsx +++ b/src/view/com/modals/Modal.web.tsx @@ -6,7 +6,6 @@ import {usePalette} from '#/lib/hooks/usePalette' import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' import {type Modal as ModalIface} from '#/state/modals' import {useModalControls, useModals} from '#/state/modals' -import * as DeleteAccountModal from './DeleteAccount' import * as ContentLanguagesSettingsModal from './lang-settings/ContentLanguagesSettings' import * as UserAddRemoveLists from './UserAddRemoveLists' @@ -48,8 +47,6 @@ function Modal({modal}: {modal: ModalIface}) { let element if (modal.name === 'user-add-remove-lists') { element = - } else if (modal.name === 'delete-account') { - element = } else if (modal.name === 'content-languages-settings') { element = } else {