import React from 'react' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useNavigation} from '@react-navigation/native' import {NavigationProp} from 'lib/routes/types' import {isNative} from 'platform/detection' import {useLeaveConvo} from 'state/queries/messages/leave-conversation' import * as Toast from 'view/com/util/Toast' import {DialogOuterProps} from '#/components/Dialog' import * as Prompt from '#/components/Prompt' export function LeaveConvoPrompt({ control, convoId, currentScreen, }: { control: DialogOuterProps['control'] convoId: string currentScreen: 'list' | 'conversation' }) { const {_} = useLingui() const navigation = useNavigation() const {mutate: leaveConvo} = useLeaveConvo(convoId, { onSuccess: () => { if (currentScreen === 'conversation') { navigation.replace( 'Messages', isNative ? { animation: 'pop', } : {}, ) } }, onError: () => { Toast.show(_(msg`Could not leave chat`)) }, }) return ( ) }