Bluesky app fork with some witchin' additions 馃挮 witchsky.app
bluesky fork client
120
fork

Configure Feed

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

at a876aae44ea07494ebea9727350aa060b81f317b 84 lines 2.2 kB view raw
1import {useCallback} from 'react' 2import {msg} from '@lingui/core/macro' 3import {useLingui} from '@lingui/react' 4 5import {logger} from '#/logger' 6import {useGetConvoForMembers} from '#/state/queries/messages/get-convo-for-members' 7import * as Dialog from '#/components/Dialog' 8import {SearchablePeopleList} from '#/components/dialogs/SearchablePeopleList' 9import * as Toast from '#/components/Toast' 10import {useAnalytics} from '#/analytics' 11 12export function SendViaChatDialog({ 13 control, 14 onSelectChat, 15}: { 16 control: Dialog.DialogControlProps 17 onSelectChat: (chatId: string) => void 18}) { 19 return ( 20 <Dialog.Outer 21 control={control} 22 testID="sendViaChatChatDialog" 23 nativeOptions={{fullHeight: true}}> 24 <Dialog.Handle /> 25 <SendViaChatDialogInner control={control} onSelectChat={onSelectChat} /> 26 </Dialog.Outer> 27 ) 28} 29 30function SendViaChatDialogInner({ 31 control, 32 onSelectChat, 33}: { 34 control: Dialog.DialogControlProps 35 onSelectChat: (chatId: string) => void 36}) { 37 const {_} = useLingui() 38 const ax = useAnalytics() 39 const {mutate: createChat} = useGetConvoForMembers({ 40 onSuccess: data => { 41 onSelectChat(data.convo.id) 42 43 if (!data.convo.lastMessage) { 44 ax.metric('chat:create', {logContext: 'SendViaChatDialog'}) 45 } 46 ax.metric('chat:open', {logContext: 'SendViaChatDialog'}) 47 }, 48 onError: error => { 49 logger.error('Failed to share post to chat', {message: error}) 50 Toast.show(_(msg`An issue occurred while trying to open the chat`), { 51 type: 'error', 52 }) 53 }, 54 }) 55 56 const onSelectExistingChat = useCallback( 57 (chatId: string) => { 58 control.close(() => onSelectChat(chatId)) 59 }, 60 [control, onSelectChat], 61 ) 62 63 const onCreateChat = useCallback( 64 (did: string) => { 65 control.close(() => createChat([did])) 66 }, 67 [control, createChat], 68 ) 69 70 return ( 71 <SearchablePeopleList 72 title={_(msg`Send post to...`)} 73 onSelectChat={chat => { 74 if (chat.kind === 'user') { 75 onCreateChat(chat.did) 76 } else { 77 onSelectExistingChat(chat.id) 78 } 79 }} 80 showRecentConvos 81 sortByMessageDeclaration 82 /> 83 ) 84}