diff options
author | Hailey <me@haileyok.com> | 2024-05-17 14:21:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-17 16:21:15 -0500 |
commit | d02e0884c40adebe3799254395d933205b104a86 (patch) | |
tree | 00cd164d727072ad04179662a2d7bfe914691ba9 /src/components/dms/LeaveConvoPrompt.tsx | |
parent | 1b47ea7367c7d0f37557d8f07329c3b6f97a5e03 (diff) | |
download | voidsky-d02e0884c40adebe3799254395d933205b104a86.tar.zst |
[🐴] Block Info (#4068)
* get the damn thing in there 😮💨 * more cleanup and little fixes another nit nit small annoyance add a comment only use `scrollTo` when necessary remove now unnecessary styles * move padding out * add unblock function * rm need for moderationpts * ? * ?? * extract leaveconvoprompt * move `setHasScrolled` to `onContentSizeChanged` * account for block footer * wrap up nit make sure recipient is loaded before showing refactor to hide chat input typo squigglie add report dialog finalize delete implement custom animation add configurable replace animation add leave convo to block options * correct functionality for report * moev component to another file * maybe... * fix chat item * improve * remove unused gtmobile * nit * more cleanup * more cleanup * fix merge * fix header * few more changes * nit * remove old
Diffstat (limited to 'src/components/dms/LeaveConvoPrompt.tsx')
-rw-r--r-- | src/components/dms/LeaveConvoPrompt.tsx | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/components/dms/LeaveConvoPrompt.tsx b/src/components/dms/LeaveConvoPrompt.tsx new file mode 100644 index 000000000..1c42dbca0 --- /dev/null +++ b/src/components/dms/LeaveConvoPrompt.tsx @@ -0,0 +1,55 @@ +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<NavigationProp>() + + const {mutate: leaveConvo} = useLeaveConvo(convoId, { + onSuccess: () => { + if (currentScreen === 'conversation') { + navigation.replace( + 'Messages', + isNative + ? { + animation: 'pop', + } + : {}, + ) + } + }, + onError: () => { + Toast.show(_(msg`Could not leave chat`)) + }, + }) + + return ( + <Prompt.Basic + control={control} + title={_(msg`Leave conversation`)} + description={_( + msg`Are you sure you want to leave this conversation? Your messages will be deleted for you, but not for the other participant.`, + )} + confirmButtonCta={_(msg`Leave`)} + confirmButtonColor="negative" + onConfirm={leaveConvo} + /> + ) +} |