Bluesky app fork with some witchin' additions 馃挮
at feat/tealfm 53 lines 1.6 kB view raw
1import {msg} from '@lingui/macro' 2import {useLingui} from '@lingui/react' 3import {StackActions, useNavigation} from '@react-navigation/native' 4 5import {type NavigationProp} from '#/lib/routes/types' 6import {useLeaveConvo} from '#/state/queries/messages/leave-conversation' 7import * as Toast from '#/view/com/util/Toast' 8import {type DialogOuterProps} from '#/components/Dialog' 9import * as Prompt from '#/components/Prompt' 10import {IS_NATIVE} from '#/env' 11 12export function LeaveConvoPrompt({ 13 control, 14 convoId, 15 currentScreen, 16 hasMessages = true, 17}: { 18 control: DialogOuterProps['control'] 19 convoId: string 20 currentScreen: 'list' | 'conversation' 21 hasMessages?: boolean 22}) { 23 const {_} = useLingui() 24 const navigation = useNavigation<NavigationProp>() 25 26 const {mutate: leaveConvo} = useLeaveConvo(convoId, { 27 onMutate: () => { 28 if (currentScreen === 'conversation') { 29 navigation.dispatch( 30 StackActions.replace('Messages', IS_NATIVE ? {animation: 'pop'} : {}), 31 ) 32 } 33 }, 34 onError: () => { 35 Toast.show(_(msg`Could not leave chat`), 'xmark') 36 }, 37 }) 38 39 return ( 40 <Prompt.Basic 41 control={control} 42 title={_(msg`Leave conversation`)} 43 description={_( 44 hasMessages 45 ? msg`Are you sure you want to leave this conversation? Your messages will be deleted for you, but not for the other participant.` 46 : msg`Are you sure you want to leave this conversation?`, 47 )} 48 confirmButtonCta={_(msg`Leave`)} 49 confirmButtonColor="negative" 50 onConfirm={() => leaveConvo()} 51 /> 52 ) 53}