Bluesky app fork with some witchin' additions 馃挮
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at f8975036440051185486f6b2c00a201ef2e18a8c 128 lines 3.8 kB view raw
1import React from 'react' 2import {View} from 'react-native' 3import {msg, Trans} from '@lingui/macro' 4import {useLingui} from '@lingui/react' 5 6import {logger} from '#/logger' 7import {useAgent, useSessionApi} from '#/state/session' 8import {atoms as a, useTheme} from '#/alf' 9import {Button, ButtonIcon, ButtonText} from '#/components/Button' 10import {type DialogOuterProps} from '#/components/Dialog' 11import {Divider} from '#/components/Divider' 12import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo' 13import {Loader} from '#/components/Loader' 14import * as Prompt from '#/components/Prompt' 15import {Text} from '#/components/Typography' 16 17export function DeactivateAccountDialog({ 18 control, 19}: { 20 control: DialogOuterProps['control'] 21}) { 22 return ( 23 <Prompt.Outer control={control}> 24 <DeactivateAccountDialogInner control={control} /> 25 </Prompt.Outer> 26 ) 27} 28 29function DeactivateAccountDialogInner({ 30 control, 31}: { 32 control: DialogOuterProps['control'] 33}) { 34 const t = useTheme() 35 const {_} = useLingui() 36 const agent = useAgent() 37 const {logoutCurrentAccount} = useSessionApi() 38 const [pending, setPending] = React.useState(false) 39 const [error, setError] = React.useState<string | undefined>() 40 41 const handleDeactivate = React.useCallback(async () => { 42 try { 43 setPending(true) 44 await agent.com.atproto.server.deactivateAccount({}) 45 control.close(() => { 46 logoutCurrentAccount('Deactivated') 47 }) 48 } catch (e: any) { 49 switch (e.message) { 50 case 'Bad token scope': 51 setError( 52 _( 53 msg`You're signed in with an App Password. Please sign in with your main password to continue deactivating your account.`, 54 ), 55 ) 56 break 57 default: 58 setError(_(msg`Something went wrong, please try again`)) 59 break 60 } 61 62 logger.error(e, { 63 message: 'Failed to deactivate account', 64 }) 65 } finally { 66 setPending(false) 67 } 68 }, [agent, control, logoutCurrentAccount, _, setPending]) 69 70 return ( 71 <> 72 <Prompt.TitleText>{_(msg`Deactivate account`)}</Prompt.TitleText> 73 <Prompt.DescriptionText> 74 <Trans> 75 Your profile, posts, feeds, and lists will no longer be visible to 76 other Bluesky users. You can reactivate your account at any time by 77 logging in. 78 </Trans> 79 </Prompt.DescriptionText> 80 81 <View style={[a.pb_xl]}> 82 <Divider /> 83 <View style={[a.gap_sm, a.pt_lg, a.pb_xl]}> 84 <Text style={[t.atoms.text_contrast_medium, a.leading_snug]}> 85 <Trans> 86 There is no time limit for account deactivation, come back any 87 time. 88 </Trans> 89 </Text> 90 <Text style={[t.atoms.text_contrast_medium, a.leading_snug]}> 91 <Trans> 92 If you're trying to change your handle or email, do so before you 93 deactivate. 94 </Trans> 95 </Text> 96 </View> 97 98 <Divider /> 99 </View> 100 <Prompt.Actions> 101 <Button 102 color="negative" 103 size="large" 104 label={_(msg`Yes, deactivate`)} 105 onPress={handleDeactivate}> 106 <ButtonText>{_(msg`Yes, deactivate`)}</ButtonText> 107 {pending && <ButtonIcon icon={Loader} position="right" />} 108 </Button> 109 <Prompt.Cancel /> 110 </Prompt.Actions> 111 112 {error && ( 113 <View 114 style={[ 115 a.flex_row, 116 a.gap_sm, 117 a.mt_md, 118 a.p_md, 119 a.rounded_sm, 120 t.atoms.bg_contrast_25, 121 ]}> 122 <CircleInfo size="md" fill={t.palette.negative_400} /> 123 <Text style={[a.flex_1, a.leading_snug]}>{error}</Text> 124 </View> 125 )} 126 </> 127 ) 128}