UNPKG

stream-chat-react-native-core

Version:

The official React Native and Expo components for Stream Chat, a service for building chat applications

96 lines (91 loc) 2.61 kB
import { useMemo } from 'react'; import type { ThreadContextValue } from '../../threadContext/ThreadContext'; import type { MessageInputContextValue } from '../MessageInputContext'; export const useCreateMessageInputContext = ({ additionalTextInputProps, allowSendBeforeAttachmentsUpload, asyncMessagesLockDistance, asyncMessagesMinimumPressDuration, asyncMessagesSlideToCancelDistance, audioRecordingSendOnComplete, attachmentPickerBottomSheetHeight, attachmentSelectionBarHeight, audioRecordingEnabled, closeAttachmentPicker, closePollCreationDialog, compressImageQuality, createPollOptionGap, editMessage, focusInputOnPickerClose, handleAttachButtonPress, hasCameraPicker, hasCommands, hasFilePicker, hasImagePicker, inputBoxRef, messageInputFloating, messageInputHeightStore, openAttachmentPicker, openPollCreationDialog, pickAndUploadImageFromNativePicker, pickFile, sendMessage, setInputBoxRef, setInputRef, showPollCreationDialog, takeAndUploadImage, uploadNewFile, audioRecorderManager, startVoiceRecording, deleteVoiceRecording, uploadVoiceRecording, stopVoiceRecording, thread, }: MessageInputContextValue & Pick<ThreadContextValue, 'thread'>) => { const threadId = thread?.id; const messageInputContext: MessageInputContextValue = useMemo( () => ({ additionalTextInputProps, allowSendBeforeAttachmentsUpload, asyncMessagesLockDistance, asyncMessagesMinimumPressDuration, asyncMessagesSlideToCancelDistance, audioRecordingSendOnComplete, attachmentPickerBottomSheetHeight, attachmentSelectionBarHeight, audioRecordingEnabled, closeAttachmentPicker, closePollCreationDialog, compressImageQuality, createPollOptionGap, editMessage, focusInputOnPickerClose, handleAttachButtonPress, hasCameraPicker, hasCommands, hasFilePicker, hasImagePicker, inputBoxRef, messageInputFloating, messageInputHeightStore, openAttachmentPicker, openPollCreationDialog, pickAndUploadImageFromNativePicker, pickFile, sendMessage, setInputBoxRef, setInputRef, showPollCreationDialog, takeAndUploadImage, uploadNewFile, audioRecorderManager, startVoiceRecording, deleteVoiceRecording, uploadVoiceRecording, stopVoiceRecording, }), // eslint-disable-next-line react-hooks/exhaustive-deps [threadId, showPollCreationDialog, allowSendBeforeAttachmentsUpload], ); return messageInputContext; };