stream-chat-react-native-core 5.22.0-beta.9 → 5.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/Attachment/AudioAttachment.js +12 -12
- package/lib/commonjs/components/Attachment/AudioAttachment.js.map +1 -1
- package/lib/commonjs/components/Channel/Channel.js +65 -46
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateChannelContext.js +2 -0
- package/lib/commonjs/components/Channel/hooks/useCreateChannelContext.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js +2 -2
- package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js +19 -19
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/commonjs/components/MessageInput/ImageUploadPreview.js +13 -13
- package/lib/commonjs/components/MessageInput/ImageUploadPreview.js.map +1 -1
- package/lib/commonjs/contexts/channelContext/ChannelContext.js +2 -2
- package/lib/commonjs/contexts/channelContext/ChannelContext.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +61 -40
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +2 -2
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/hooks/useMessageDetailsForState.js.map +1 -1
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/commonjs/i18n/en.json +1 -1
- package/lib/commonjs/i18n/fr.json +50 -50
- package/lib/commonjs/i18n/hi.json +50 -50
- package/lib/commonjs/i18n/it.json +50 -50
- package/lib/commonjs/i18n/nl.json +50 -50
- package/lib/commonjs/i18n/ru.json +50 -50
- package/lib/commonjs/i18n/tr.json +50 -50
- package/lib/commonjs/types/types.js.map +1 -1
- package/lib/commonjs/utils/compressImage.js +37 -0
- package/lib/commonjs/utils/compressImage.js.map +1 -0
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/AudioAttachment.js +12 -12
- package/lib/module/components/Attachment/AudioAttachment.js.map +1 -1
- package/lib/module/components/Channel/Channel.js +65 -46
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateChannelContext.js +2 -0
- package/lib/module/components/Channel/hooks/useCreateChannelContext.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js +2 -2
- package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
- package/lib/module/components/MessageInput/FileUploadPreview.js +19 -19
- package/lib/module/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/module/components/MessageInput/ImageUploadPreview.js +13 -13
- package/lib/module/components/MessageInput/ImageUploadPreview.js.map +1 -1
- package/lib/module/contexts/channelContext/ChannelContext.js +2 -2
- package/lib/module/contexts/channelContext/ChannelContext.js.map +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +61 -40
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +2 -2
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
- package/lib/module/contexts/messageInputContext/hooks/useMessageDetailsForState.js.map +1 -1
- package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/module/i18n/en.json +1 -1
- package/lib/module/i18n/fr.json +50 -50
- package/lib/module/i18n/hi.json +50 -50
- package/lib/module/i18n/it.json +50 -50
- package/lib/module/i18n/nl.json +50 -50
- package/lib/module/i18n/ru.json +50 -50
- package/lib/module/i18n/tr.json +50 -50
- package/lib/module/types/types.js.map +1 -1
- package/lib/module/utils/compressImage.js +37 -0
- package/lib/module/utils/compressImage.js.map +1 -0
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Attachment/AudioAttachment.d.ts +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateChannelContext.d.ts +1 -1
- package/lib/typescript/components/Message/hooks/useMessageActionHandlers.d.ts +1 -1
- package/lib/typescript/components/Message/hooks/useMessageActions.d.ts +1 -1
- package/lib/typescript/contexts/channelContext/ChannelContext.d.ts +5 -0
- package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +3 -23
- package/lib/typescript/contexts/messageInputContext/hooks/useMessageDetailsForState.d.ts +2 -2
- package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +2 -2
- package/lib/typescript/i18n/en.json +1 -1
- package/lib/typescript/i18n/fr.json +50 -50
- package/lib/typescript/i18n/hi.json +50 -50
- package/lib/typescript/i18n/it.json +50 -50
- package/lib/typescript/i18n/nl.json +50 -50
- package/lib/typescript/i18n/ru.json +50 -50
- package/lib/typescript/i18n/tr.json +50 -50
- package/lib/typescript/types/types.d.ts +20 -0
- package/lib/typescript/utils/compressImage.d.ts +8 -0
- package/package.json +1 -1
- package/src/components/Attachment/AudioAttachment.tsx +2 -1
- package/src/components/Channel/Channel.tsx +32 -8
- package/src/components/Channel/hooks/useCreateChannelContext.ts +2 -0
- package/src/components/Channel/hooks/useCreateInputMessageInputContext.ts +2 -9
- package/src/components/MessageInput/FileUploadPreview.tsx +1 -2
- package/src/components/MessageInput/ImageUploadPreview.tsx +1 -2
- package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewExpo.test.tsx +1 -1
- package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewNative.test.tsx +1 -1
- package/src/contexts/channelContext/ChannelContext.tsx +5 -0
- package/src/contexts/messageInputContext/MessageInputContext.tsx +80 -68
- package/src/contexts/messageInputContext/__tests__/__snapshots__/sendMessage.test.tsx.snap +3 -3
- package/src/contexts/messageInputContext/hooks/useCreateMessageInputContext.ts +2 -2
- package/src/contexts/messageInputContext/hooks/useMessageDetailsForState.ts +2 -2
- package/src/contexts/messagesContext/MessagesContext.tsx +2 -2
- package/src/i18n/en.json +1 -1
- package/src/i18n/fr.json +50 -50
- package/src/i18n/hi.json +50 -50
- package/src/i18n/it.json +50 -50
- package/src/i18n/nl.json +50 -50
- package/src/i18n/ru.json +50 -50
- package/src/i18n/tr.json +50 -50
- package/src/types/types.ts +23 -0
- package/src/utils/compressImage.ts +32 -0
- package/src/version.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_UploadProgressIndicator","_contexts","_MessageInputContext","_ThemeContext","_TranslationContext","_Close","_Warning","_utils","_this","_jsxFileName","IMAGE_PREVIEW_SIZE","WARNING_ICON_SIZE","styles","StyleSheet","create","dismiss","borderRadius","position","right","top","fileSizeText","fontSize","paddingHorizontal","flatList","paddingBottom","iconContainer","alignItems","flexDirection","justifyContent","itemContainer","height","marginLeft","unsupportedImage","bottom","marginHorizontal","upload","width","warningIconStyle","marginTop","warningText","color","ImageUploadPreviewWithContext","props","enableOfflineSupport","imageUploads","removeImage","uploadImage","_useTheme","useTheme","_useTheme$theme$messa","theme","messageInput","imageUploadPreview","UnsupportedImageTypeIndicator","_ref","indicatorType","_useTheme2","_useTheme2$theme$colo","colors","accent_red","overlay","white","_useTranslationContex","useTranslationContext","t","ProgressIndicatorTypes","NOT_SUPPORTED","createElement","View","style","backgroundColor","__self","__source","fileName","lineNumber","columnNumber","Warning","pathFill","Text","renderItem","_ref2","index","item","getIndicatorTypeForFileState","state","itemMarginForIndex","length","marginRight","UploadProgressIndicator","action","newImage","type","Image","resizeMode","source","uri","file","url","DismissUpload","onPress","id","FlatList","data","getItemLayout","_","offset","horizontal","keyExtractor","_ref3","_useTheme3","_useTheme3$theme","_useTheme3$theme$colo","_useTheme3$theme$mess","dismissIconColor","TouchableOpacity","testID","Close","areEqual","prevProps","nextProps","prevImageUploads","nextImageUploads","every","prevImageUpload","MemoizedImageUploadPreviewWithContext","React","memo","ImageUploadPreview","_useChatContext","useChatContext","_useMessageInputConte","useMessageInputContext","_extends2","exports","displayName"],"sources":["ImageUploadPreview.tsx"],"sourcesContent":["import React from 'react';\nimport {\n FlatList,\n Image,\n StyleSheet,\n Text,\n TouchableOpacity,\n TouchableOpacityProps,\n View,\n} from 'react-native';\n\nimport { UploadProgressIndicator } from './UploadProgressIndicator';\n\nimport { ChatContextValue, useChatContext } from '../../contexts';\nimport {\n ImageUpload,\n MessageInputContextValue,\n useMessageInputContext,\n} from '../../contexts/messageInputContext/MessageInputContext';\nimport { useTheme } from '../../contexts/themeContext/ThemeContext';\nimport { useTranslationContext } from '../../contexts/translationContext/TranslationContext';\nimport { Close } from '../../icons/Close';\nimport { Warning } from '../../icons/Warning';\nimport type { DefaultStreamChatGenerics } from '../../types/types';\nimport { getIndicatorTypeForFileState, ProgressIndicatorTypes } from '../../utils/utils';\n\nconst IMAGE_PREVIEW_SIZE = 100;\nconst WARNING_ICON_SIZE = 16;\n\nconst styles = StyleSheet.create({\n dismiss: {\n borderRadius: 24,\n position: 'absolute',\n right: 8,\n top: 8,\n },\n fileSizeText: {\n fontSize: 12,\n paddingHorizontal: 10,\n },\n flatList: { paddingBottom: 12 },\n iconContainer: {\n alignItems: 'center',\n flexDirection: 'row',\n justifyContent: 'center',\n },\n itemContainer: {\n flexDirection: 'row',\n height: IMAGE_PREVIEW_SIZE,\n marginLeft: 8,\n },\n unsupportedImage: {\n borderRadius: 20,\n bottom: 8,\n flexDirection: 'row',\n marginHorizontal: 3,\n position: 'absolute',\n },\n upload: {\n borderRadius: 10,\n height: IMAGE_PREVIEW_SIZE,\n width: IMAGE_PREVIEW_SIZE,\n },\n warningIconStyle: {\n borderRadius: 24,\n marginTop: 6,\n },\n warningText: {\n alignItems: 'center',\n color: 'black',\n fontSize: 10,\n justifyContent: 'center',\n marginHorizontal: 4,\n },\n});\n\ntype ImageUploadPreviewPropsWithContext<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Pick<\n MessageInputContextValue<StreamChatGenerics>,\n 'imageUploads' | 'removeImage' | 'uploadImage'\n> &\n Pick<ChatContextValue<StreamChatGenerics>, 'enableOfflineSupport'>;\n\nexport type ImageUploadPreviewProps<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Partial<ImageUploadPreviewPropsWithContext<StreamChatGenerics>>;\n\ntype ImageUploadPreviewItem = { index: number; item: ImageUpload };\n\nconst ImageUploadPreviewWithContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: ImageUploadPreviewPropsWithContext<StreamChatGenerics>,\n) => {\n const { enableOfflineSupport, imageUploads, removeImage, uploadImage } = props;\n\n const {\n theme: {\n messageInput: {\n imageUploadPreview: { flatList, itemContainer, upload },\n },\n },\n } = useTheme();\n\n const UnsupportedImageTypeIndicator = ({\n indicatorType,\n }: {\n indicatorType: typeof ProgressIndicatorTypes[keyof typeof ProgressIndicatorTypes] | null;\n }) => {\n const {\n theme: {\n colors: { accent_red, overlay, white },\n },\n } = useTheme();\n\n const { t } = useTranslationContext();\n return indicatorType === ProgressIndicatorTypes.NOT_SUPPORTED ? (\n <View style={[styles.unsupportedImage, { backgroundColor: overlay }]}>\n <View style={[styles.iconContainer]}>\n <Warning\n height={WARNING_ICON_SIZE}\n pathFill={accent_red}\n style={styles.warningIconStyle}\n width={WARNING_ICON_SIZE}\n />\n <Text style={[styles.warningText, { color: white }]}>{t('Not supported')}</Text>\n </View>\n </View>\n ) : null;\n };\n\n const renderItem = ({ index, item }: ImageUploadPreviewItem) => {\n const indicatorType = getIndicatorTypeForFileState(item.state, enableOfflineSupport);\n const itemMarginForIndex = index === imageUploads.length - 1 ? { marginRight: 8 } : {};\n\n return (\n <View style={[styles.itemContainer, itemMarginForIndex, itemContainer]}>\n <UploadProgressIndicator\n action={() => {\n uploadImage({ newImage: item });\n }}\n style={styles.upload}\n type={indicatorType}\n >\n <Image\n resizeMode='cover'\n source={{ uri: item.file.uri || item.url }}\n style={[styles.upload, upload]}\n />\n </UploadProgressIndicator>\n <DismissUpload\n onPress={() => {\n removeImage(item.id);\n }}\n />\n <UnsupportedImageTypeIndicator indicatorType={indicatorType} />\n </View>\n );\n };\n\n return imageUploads.length > 0 ? (\n <FlatList\n data={imageUploads}\n getItemLayout={(_, index) => ({\n index,\n length: IMAGE_PREVIEW_SIZE + 8,\n offset: (IMAGE_PREVIEW_SIZE + 8) * index,\n })}\n horizontal\n keyExtractor={(item) => item.id}\n renderItem={renderItem}\n style={[styles.flatList, flatList]}\n />\n ) : null;\n};\n\ntype DismissUploadProps = Pick<TouchableOpacityProps, 'onPress'>;\n\nconst DismissUpload = ({ onPress }: DismissUploadProps) => {\n const {\n theme: {\n colors: { overlay, white },\n messageInput: {\n imageUploadPreview: { dismiss, dismissIconColor },\n },\n },\n } = useTheme();\n\n return (\n <TouchableOpacity\n onPress={onPress}\n style={[styles.dismiss, { backgroundColor: overlay }, dismiss]}\n testID='remove-image-upload-preview'\n >\n <Close pathFill={dismissIconColor || white} />\n </TouchableOpacity>\n );\n};\n\nconst areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(\n prevProps: ImageUploadPreviewPropsWithContext<StreamChatGenerics>,\n nextProps: ImageUploadPreviewPropsWithContext<StreamChatGenerics>,\n) => {\n const { imageUploads: prevImageUploads } = prevProps;\n const { imageUploads: nextImageUploads } = nextProps;\n\n return (\n prevImageUploads.length === nextImageUploads.length &&\n prevImageUploads.every(\n (prevImageUpload, index) => prevImageUpload.state === nextImageUploads[index].state,\n )\n );\n};\n\nconst MemoizedImageUploadPreviewWithContext = React.memo(\n ImageUploadPreviewWithContext,\n areEqual,\n) as typeof ImageUploadPreviewWithContext;\n\n/**\n * UI Component to preview the images set for upload\n */\nexport const ImageUploadPreview = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: ImageUploadPreviewProps<StreamChatGenerics>,\n) => {\n const { enableOfflineSupport } = useChatContext<StreamChatGenerics>();\n const { imageUploads, removeImage, uploadImage } = useMessageInputContext<StreamChatGenerics>();\n\n return (\n <MemoizedImageUploadPreviewWithContext\n {...{ imageUploads, removeImage, uploadImage }}\n {...{ enableOfflineSupport }}\n {...props}\n />\n );\n};\n\nImageUploadPreview.displayName = 'ImageUploadPreview{messageInput{imageUploadPreview}}';\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAUA,IAAAE,wBAAA,GAAAF,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,oBAAA,GAAAJ,OAAA;AAKA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,mBAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAEA,IAAAS,MAAA,GAAAT,OAAA;AAAyF,IAAAU,KAAA;EAAAC,YAAA;AAEzF,IAAMC,kBAAkB,GAAG,GAAG;AAC9B,IAAMC,iBAAiB,GAAG,EAAE;AAE5B,IAAMC,MAAM,GAAGC,uBAAU,CAACC,MAAM,CAAC;EAC/BC,OAAO,EAAE;IACPC,YAAY,EAAE,EAAE;IAChBC,QAAQ,EAAE,UAAU;IACpBC,KAAK,EAAE,CAAC;IACRC,GAAG,EAAE;EACP,CAAC;EACDC,YAAY,EAAE;IACZC,QAAQ,EAAE,EAAE;IACZC,iBAAiB,EAAE;EACrB,CAAC;EACDC,QAAQ,EAAE;IAAEC,aAAa,EAAE;EAAG,CAAC;EAC/BC,aAAa,EAAE;IACbC,UAAU,EAAE,QAAQ;IACpBC,aAAa,EAAE,KAAK;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDC,aAAa,EAAE;IACbF,aAAa,EAAE,KAAK;IACpBG,MAAM,EAAEpB,kBAAkB;IAC1BqB,UAAU,EAAE;EACd,CAAC;EACDC,gBAAgB,EAAE;IAChBhB,Y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BAAA;AAEFA,kBAAkB,CAACO,WAAW,GAAG,sDAAsD"}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_UploadProgressIndicator","_contexts","_MessageInputContext","_ThemeContext","_TranslationContext","_Close","_Warning","_utils","_this","_jsxFileName","IMAGE_PREVIEW_SIZE","WARNING_ICON_SIZE","styles","StyleSheet","create","dismiss","borderRadius","position","right","top","fileSizeText","fontSize","paddingHorizontal","flatList","paddingBottom","iconContainer","alignItems","flexDirection","justifyContent","itemContainer","height","marginLeft","unsupportedImage","bottom","marginHorizontal","upload","width","warningIconStyle","marginTop","warningText","color","ImageUploadPreviewWithContext","props","enableOfflineSupport","imageUploads","removeImage","uploadImage","_useTheme","useTheme","_useTheme$theme$messa","theme","messageInput","imageUploadPreview","UnsupportedImageTypeIndicator","_ref","indicatorType","_useTheme2","_useTheme2$theme$colo","colors","accent_red","overlay","white","_useTranslationContex","useTranslationContext","t","ProgressIndicatorTypes","NOT_SUPPORTED","createElement","View","style","backgroundColor","__self","__source","fileName","lineNumber","columnNumber","Warning","pathFill","Text","renderItem","_ref2","index","item","getIndicatorTypeForFileState","state","itemMarginForIndex","length","marginRight","UploadProgressIndicator","action","newImage","type","Image","resizeMode","source","uri","file","url","DismissUpload","onPress","id","FlatList","data","getItemLayout","_","offset","horizontal","keyExtractor","_ref3","_useTheme3","_useTheme3$theme","_useTheme3$theme$colo","_useTheme3$theme$mess","dismissIconColor","TouchableOpacity","testID","Close","areEqual","prevProps","nextProps","prevImageUploads","nextImageUploads","every","prevImageUpload","MemoizedImageUploadPreviewWithContext","React","memo","ImageUploadPreview","_useChatContext","useChatContext","_useMessageInputConte","useMessageInputContext","_extends2","exports","displayName"],"sources":["ImageUploadPreview.tsx"],"sourcesContent":["import React from 'react';\nimport {\n FlatList,\n Image,\n StyleSheet,\n Text,\n TouchableOpacity,\n TouchableOpacityProps,\n View,\n} from 'react-native';\n\nimport { UploadProgressIndicator } from './UploadProgressIndicator';\n\nimport { ChatContextValue, useChatContext } from '../../contexts';\nimport {\n MessageInputContextValue,\n useMessageInputContext,\n} from '../../contexts/messageInputContext/MessageInputContext';\nimport { useTheme } from '../../contexts/themeContext/ThemeContext';\nimport { useTranslationContext } from '../../contexts/translationContext/TranslationContext';\nimport { Close } from '../../icons/Close';\nimport { Warning } from '../../icons/Warning';\nimport type { DefaultStreamChatGenerics, ImageUpload } from '../../types/types';\nimport { getIndicatorTypeForFileState, ProgressIndicatorTypes } from '../../utils/utils';\n\nconst IMAGE_PREVIEW_SIZE = 100;\nconst WARNING_ICON_SIZE = 16;\n\nconst styles = StyleSheet.create({\n dismiss: {\n borderRadius: 24,\n position: 'absolute',\n right: 8,\n top: 8,\n },\n fileSizeText: {\n fontSize: 12,\n paddingHorizontal: 10,\n },\n flatList: { paddingBottom: 12 },\n iconContainer: {\n alignItems: 'center',\n flexDirection: 'row',\n justifyContent: 'center',\n },\n itemContainer: {\n flexDirection: 'row',\n height: IMAGE_PREVIEW_SIZE,\n marginLeft: 8,\n },\n unsupportedImage: {\n borderRadius: 20,\n bottom: 8,\n flexDirection: 'row',\n marginHorizontal: 3,\n position: 'absolute',\n },\n upload: {\n borderRadius: 10,\n height: IMAGE_PREVIEW_SIZE,\n width: IMAGE_PREVIEW_SIZE,\n },\n warningIconStyle: {\n borderRadius: 24,\n marginTop: 6,\n },\n warningText: {\n alignItems: 'center',\n color: 'black',\n fontSize: 10,\n justifyContent: 'center',\n marginHorizontal: 4,\n },\n});\n\ntype ImageUploadPreviewPropsWithContext<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Pick<\n MessageInputContextValue<StreamChatGenerics>,\n 'imageUploads' | 'removeImage' | 'uploadImage'\n> &\n Pick<ChatContextValue<StreamChatGenerics>, 'enableOfflineSupport'>;\n\nexport type ImageUploadPreviewProps<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Partial<ImageUploadPreviewPropsWithContext<StreamChatGenerics>>;\n\ntype ImageUploadPreviewItem = { index: number; item: ImageUpload };\n\nconst ImageUploadPreviewWithContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: ImageUploadPreviewPropsWithContext<StreamChatGenerics>,\n) => {\n const { enableOfflineSupport, imageUploads, removeImage, uploadImage } = props;\n\n const {\n theme: {\n messageInput: {\n imageUploadPreview: { flatList, itemContainer, upload },\n },\n },\n } = useTheme();\n\n const UnsupportedImageTypeIndicator = ({\n indicatorType,\n }: {\n indicatorType: typeof ProgressIndicatorTypes[keyof typeof ProgressIndicatorTypes] | null;\n }) => {\n const {\n theme: {\n colors: { accent_red, overlay, white },\n },\n } = useTheme();\n\n const { t } = useTranslationContext();\n return indicatorType === ProgressIndicatorTypes.NOT_SUPPORTED ? (\n <View style={[styles.unsupportedImage, { backgroundColor: overlay }]}>\n <View style={[styles.iconContainer]}>\n <Warning\n height={WARNING_ICON_SIZE}\n pathFill={accent_red}\n style={styles.warningIconStyle}\n width={WARNING_ICON_SIZE}\n />\n <Text style={[styles.warningText, { color: white }]}>{t('Not supported')}</Text>\n </View>\n </View>\n ) : null;\n };\n\n const renderItem = ({ index, item }: ImageUploadPreviewItem) => {\n const indicatorType = getIndicatorTypeForFileState(item.state, enableOfflineSupport);\n const itemMarginForIndex = index === imageUploads.length - 1 ? { marginRight: 8 } : {};\n\n return (\n <View style={[styles.itemContainer, itemMarginForIndex, itemContainer]}>\n <UploadProgressIndicator\n action={() => {\n uploadImage({ newImage: item });\n }}\n style={styles.upload}\n type={indicatorType}\n >\n <Image\n resizeMode='cover'\n source={{ uri: item.file.uri || item.url }}\n style={[styles.upload, upload]}\n />\n </UploadProgressIndicator>\n <DismissUpload\n onPress={() => {\n removeImage(item.id);\n }}\n />\n <UnsupportedImageTypeIndicator indicatorType={indicatorType} />\n </View>\n );\n };\n\n return imageUploads.length > 0 ? (\n <FlatList\n data={imageUploads}\n getItemLayout={(_, index) => ({\n index,\n length: IMAGE_PREVIEW_SIZE + 8,\n offset: (IMAGE_PREVIEW_SIZE + 8) * index,\n })}\n horizontal\n keyExtractor={(item) => item.id}\n renderItem={renderItem}\n style={[styles.flatList, flatList]}\n />\n ) : null;\n};\n\ntype DismissUploadProps = Pick<TouchableOpacityProps, 'onPress'>;\n\nconst DismissUpload = ({ onPress }: DismissUploadProps) => {\n const {\n theme: {\n colors: { overlay, white },\n messageInput: {\n imageUploadPreview: { dismiss, dismissIconColor },\n },\n },\n } = useTheme();\n\n return (\n <TouchableOpacity\n onPress={onPress}\n style={[styles.dismiss, { backgroundColor: overlay }, dismiss]}\n testID='remove-image-upload-preview'\n >\n <Close pathFill={dismissIconColor || white} />\n </TouchableOpacity>\n );\n};\n\nconst areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(\n prevProps: ImageUploadPreviewPropsWithContext<StreamChatGenerics>,\n nextProps: ImageUploadPreviewPropsWithContext<StreamChatGenerics>,\n) => {\n const { imageUploads: prevImageUploads } = prevProps;\n const { imageUploads: nextImageUploads } = nextProps;\n\n return (\n prevImageUploads.length === nextImageUploads.length &&\n prevImageUploads.every(\n (prevImageUpload, index) => prevImageUpload.state === nextImageUploads[index].state,\n )\n );\n};\n\nconst MemoizedImageUploadPreviewWithContext = React.memo(\n ImageUploadPreviewWithContext,\n areEqual,\n) as typeof ImageUploadPreviewWithContext;\n\n/**\n * UI Component to preview the images set for upload\n */\nexport const ImageUploadPreview = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: ImageUploadPreviewProps<StreamChatGenerics>,\n) => {\n const { enableOfflineSupport } = useChatContext<StreamChatGenerics>();\n const { imageUploads, removeImage, uploadImage } = useMessageInputContext<StreamChatGenerics>();\n\n return (\n <MemoizedImageUploadPreviewWithContext\n {...{ imageUploads, removeImage, uploadImage }}\n {...{ enableOfflineSupport }}\n {...props}\n />\n );\n};\n\nImageUploadPreview.displayName = 'ImageUploadPreview{messageInput{imageUploadPreview}}';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AgB,CAACnC,MAAM,IACnDkC,gBAAgB,CAACE,KAAK,CACpB,UAACC,eAAe,EAAE1C,KAAK;IAAA,OAAK0C,eAAe,CAACvC,KAAK,KAAKqC,gBAAgB,CAACxC,KAAK,CAAC,CAACG,KAAK;EAAA,CACrF,CAAC;AAEL,CAAC;AAED,IAAMwC,qCAAqC,GAAGC,iBAAK,CAACC,IAAI,CACtDrF,6BAA6B,EAC7B4E,QACF,CAAyC;AAKlC,IAAMU,kBAAkB,GAAG,SAArBA,kBAAkBA,CAG7BrF,KAAkD,EAC/C;EACH,IAAAsF,eAAA,GAAiC,IAAAC,wBAAc,EAAqB,CAAC;IAA7DtF,oBAAoB,GAAAqF,eAAA,CAApBrF,oBAAoB;EAC5B,IAAAuF,qBAAA,GAAmD,IAAAC,2CAAsB,EAAqB,CAAC;IAAvFvF,YAAY,GAAAsF,qBAAA,CAAZtF,YAAY;IAAEC,WAAW,GAAAqF,qBAAA,CAAXrF,WAAW;IAAEC,WAAW,GAAAoF,qBAAA,CAAXpF,WAAW;EAE9C,OACElD,MAAA,YAAAuE,aAAA,CAACyD,qCAAqC,MAAAQ,SAAA;IAC9BxF,YAAY,EAAZA,YAAY;IAAEC,WAAW,EAAXA,WAAW;IAAEC,WAAW,EAAXA,WAAW;IACtCH,oBAAoB,EAApBA;EAAoB,GACtBD,KAAK;IAAA6B,MAAA,EAAA/D,KAAA;IAAAgE,QAAA;MAAAC,QAAA,EAAAhE,YAAA;MAAAiE,UAAA;MAAAC,YAAA;IAAA;EAAA,EACV,CAAC;AAEN,CAAC;AAAC0D,OAAA,CAAAN,kBAAA,GAAAA,kBAAA;AAEFA,kBAAkB,CAACO,WAAW,GAAG,sDAAsD"}
|
|
@@ -23,7 +23,7 @@ var ChannelProvider = function ChannelProvider(_ref) {
|
|
|
23
23
|
__self: _this,
|
|
24
24
|
__source: {
|
|
25
25
|
fileName: _jsxFileName,
|
|
26
|
-
lineNumber:
|
|
26
|
+
lineNumber: 205,
|
|
27
27
|
columnNumber: 3
|
|
28
28
|
}
|
|
29
29
|
}, children);
|
|
@@ -44,7 +44,7 @@ var withChannelContext = function withChannelContext(Component) {
|
|
|
44
44
|
__self: _this,
|
|
45
45
|
__source: {
|
|
46
46
|
fileName: _jsxFileName,
|
|
47
|
-
lineNumber:
|
|
47
|
+
lineNumber: 241,
|
|
48
48
|
columnNumber: 12
|
|
49
49
|
}
|
|
50
50
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_defaultBaseContextValue","_getDisplayName","_isTestEnvironment","_this","_jsxFileName","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","ChannelContext","React","createContext","DEFAULT_BASE_CONTEXT_VALUE","exports","ChannelProvider","_ref","children","value","createElement","Provider","__self","__source","fileName","lineNumber","columnNumber","useChannelContext","contextValue","useContext","isTestEnvironment","Error","withChannelContext","Component","WithChannelContextComponent","props","channelContext","_extends2","displayName","getDisplayName"],"sources":["ChannelContext.tsx"],"sourcesContent":["import React, { PropsWithChildren, useContext } from 'react';\n\nimport type { Channel, ChannelState } from 'stream-chat';\n\nimport type { EmptyStateProps } from '../../components/Indicators/EmptyStateIndicator';\nimport type { LoadingProps } from '../../components/Indicators/LoadingIndicator';\nimport type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';\nimport { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';\n\nimport { getDisplayName } from '../utils/getDisplayName';\nimport { isTestEnvironment } from '../utils/isTestEnvironment';\n\nexport type ChannelContextValue<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n /**\n * Instance of channel object from stream-chat package.\n *\n * Please check the docs around how to create or query channel - https://getstream.io/chat/docs/javascript/creating_channels/?language=javascript\n *\n * ```\n * import { StreamChat, Channel } from 'stream-chat';\n * import { Chat, Channel} from 'stream-chat-react-native';\n *\n * const client = StreamChat.getInstance('api_key');\n * await client.connectUser('user_id', 'user_token');\n * const channel = client.channel('messaging', 'channel_id');\n * await channel.watch();\n *\n * <Chat client={client}>\n * <Channel channel={channel}>\n * </Channel>\n * </Chat>\n * ```\n *\n * @overrideType Channel\n */\n channel: Channel<StreamChatGenerics>;\n /**\n * Custom UI component to display empty state when channel has no messages.\n *\n * **Default** [EmptyStateIndicator](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/Indicators/EmptyStateIndicator.tsx)\n */\n EmptyStateIndicator: React.ComponentType<EmptyStateProps>;\n /**\n * When set to true, reactions will be limited to 1 per user. If user selects another reaction\n * then his previous reaction will be removed and replaced with new one.\n *\n * This is similar to reaction UX on [iMessage application](https://en.wikipedia.org/wiki/IMessage).\n */\n enforceUniqueReaction: boolean;\n error: boolean | Error;\n /**\n * When set to false, it will disable giphy command on MessageInput component.\n */\n giphyEnabled: boolean;\n /**\n * Hide inline date separators on channel\n */\n hideDateSeparators: boolean;\n hideStickyDateHeader: boolean;\n /**\n * Returns true if the current user has admin privileges\n */\n isAdmin: boolean;\n /**\n * Returns true if the current user is a moderator\n */\n isModerator: boolean;\n /**\n * Returns true if the current user is a owner\n */\n isOwner: boolean;\n /**\n * Loads channel around a specific message\n *\n * @param messageId If undefined, channel will be loaded at most recent message.\n */\n loadChannelAroundMessage: ({ messageId }: { messageId?: string }) => Promise<void>;\n /**\n * @deprecated use loadChannelAroundMessage instead\n *\n * Loads channel at specific message\n *\n * @param messageId If undefined, channel will be loaded at most recent message.\n * @param before Number of message to query before messageId\n * @param after Number of message to query after messageId\n */\n loadChannelAtMessage: ({\n after,\n before,\n messageId,\n }: {\n after?: number;\n before?: number;\n messageId?: string;\n }) => Promise<void>;\n loading: boolean;\n /**\n * Custom loading indicator to override the Stream default\n */\n LoadingIndicator: React.ComponentType<LoadingProps>;\n markRead: () => void;\n /**\n *\n * ```json\n * {\n * \"thierry-123\": {\n * \"id\": \"thierry-123\",\n * \"role\": \"user\",\n * \"created_at\": \"2019-04-03T14:42:47.087869Z\",\n * \"updated_at\": \"2019-04-16T09:20:03.982283Z\",\n * \"last_active\": \"2019-04-16T11:23:51.168113408+02:00\",\n * \"online\": true\n * },\n * \"vishal-123\": {\n * \"id\": \"vishal-123\",\n * \"role\": \"user\",\n * \"created_at\": \"2019-05-03T14:42:47.087869Z\",\n * \"updated_at\": \"2019-05-16T09:20:03.982283Z\",\n * \"last_active\": \"2019-06-16T11:23:51.168113408+02:00\",\n * \"online\": false\n * }\n * }\n * ```\n */\n members: ChannelState<StreamChatGenerics>['members'];\n /**\n * Custom network down indicator to override the Stream default\n */\n NetworkDownIndicator: React.ComponentType;\n read: ChannelState<StreamChatGenerics>['read'];\n reloadChannel: () => Promise<void>;\n /**\n * When true, messagelist will be scrolled to first unread message, when opened.\n */\n scrollToFirstUnreadThreshold: number;\n setLastRead: React.Dispatch<React.SetStateAction<Date | undefined>>;\n setTargetedMessage: (messageId: string) => void;\n /**\n *\n * ```json\n * {\n * \"thierry-123\": {\n * \"id\": \"thierry-123\",\n * \"role\": \"user\",\n * \"created_at\": \"2019-04-03T14:42:47.087869Z\",\n * \"updated_at\": \"2019-04-16T09:20:03.982283Z\",\n * \"last_active\": \"2019-04-16T11:23:51.168113408+02:00\",\n * \"online\": true\n * },\n * \"vishal-123\": {\n * \"id\": \"vishal-123\",\n * \"role\": \"user\",\n * \"created_at\": \"2019-05-03T14:42:47.087869Z\",\n * \"updated_at\": \"2019-05-16T09:20:03.982283Z\",\n * \"last_active\": \"2019-06-16T11:23:51.168113408+02:00\",\n * \"online\": false\n * }\n * }\n * ```\n */\n watchers: ChannelState<StreamChatGenerics>['watchers'];\n disabled?: boolean;\n enableMessageGroupingByUser?: boolean;\n isChannelActive?: boolean;\n lastRead?: Date;\n /**\n * Maximum time in milliseconds that should occur between messages\n * to still consider them grouped together\n */\n maxTimeBetweenGroupedMessages?: number;\n /**\n * Custom UI component for sticky header of channel.\n *\n * **Default** [DateHeader](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/MessageList/DateHeader.tsx)\n */\n StickyHeader?: React.ComponentType<{ dateString: string }>;\n /**\n * Id of message, around which Channel/MessageList gets loaded when opened.\n * You will see a highlighted background for targetted message, when opened.\n */\n targetedMessage?: string;\n threadList?: boolean;\n watcherCount?: ChannelState<StreamChatGenerics>['watcher_count'];\n};\n\nexport const ChannelContext = React.createContext(\n DEFAULT_BASE_CONTEXT_VALUE as ChannelContextValue,\n);\n\nexport const ChannelProvider = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n children,\n value,\n}: PropsWithChildren<{\n value: ChannelContextValue<StreamChatGenerics>;\n}>) => (\n <ChannelContext.Provider value={value as unknown as ChannelContextValue}>\n {children}\n </ChannelContext.Provider>\n);\n\nexport const useChannelContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>() => {\n const contextValue = useContext(\n ChannelContext,\n ) as unknown as ChannelContextValue<StreamChatGenerics>;\n\n if (contextValue === DEFAULT_BASE_CONTEXT_VALUE && !isTestEnvironment()) {\n throw new Error(\n `The useChannelContext hook was called outside of the ChannelContext provider. Make sure you have configured Channel component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#channel`,\n );\n }\n\n return contextValue;\n};\n/**\n * Typescript currently does not support partial inference so if ChatContext\n * typing is desired while using the HOC withChannelContext the Props for the\n * wrapped component must be provided as the first generic.\n */\nexport const withChannelContext = <\n P extends UnknownType,\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n Component: React.ComponentType<P>,\n): React.FC<Omit<P, keyof ChannelContextValue<StreamChatGenerics>>> => {\n const WithChannelContextComponent = (\n props: Omit<P, keyof ChannelContextValue<StreamChatGenerics>>,\n ) => {\n const channelContext = useChannelContext<StreamChatGenerics>();\n\n return <Component {...(props as P)} {...channelContext} />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AnC,KAAA;MAAAoC,QAAA;QAAAC,QAAA,EAAApC,YAAA;QAAAqC,UAAA;QAAAC,YAAA;MAAA;IAAA,EAAG,CAAC;EAC5D,CAAC;EACDQ,2BAA2B,CAACI,WAAW,0BAAwB,IAAAC,8BAAc,EAACN,SAAS,CAAG;EAC1F,OAAOC,2BAA2B;AACpC,CAAC;AAACnB,OAAA,CAAAiB,kBAAA,GAAAA,kBAAA"}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_defaultBaseContextValue","_getDisplayName","_isTestEnvironment","_this","_jsxFileName","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","ChannelContext","React","createContext","DEFAULT_BASE_CONTEXT_VALUE","exports","ChannelProvider","_ref","children","value","createElement","Provider","__self","__source","fileName","lineNumber","columnNumber","useChannelContext","contextValue","useContext","isTestEnvironment","Error","withChannelContext","Component","WithChannelContextComponent","props","channelContext","_extends2","displayName","getDisplayName"],"sources":["ChannelContext.tsx"],"sourcesContent":["import React, { PropsWithChildren, useContext } from 'react';\n\nimport type { Channel, ChannelState } from 'stream-chat';\n\nimport type { EmptyStateProps } from '../../components/Indicators/EmptyStateIndicator';\nimport type { LoadingProps } from '../../components/Indicators/LoadingIndicator';\nimport type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';\nimport { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';\n\nimport { getDisplayName } from '../utils/getDisplayName';\nimport { isTestEnvironment } from '../utils/isTestEnvironment';\n\nexport type ChannelContextValue<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n /**\n * Instance of channel object from stream-chat package.\n *\n * Please check the docs around how to create or query channel - https://getstream.io/chat/docs/javascript/creating_channels/?language=javascript\n *\n * ```\n * import { StreamChat, Channel } from 'stream-chat';\n * import { Chat, Channel} from 'stream-chat-react-native';\n *\n * const client = StreamChat.getInstance('api_key');\n * await client.connectUser('user_id', 'user_token');\n * const channel = client.channel('messaging', 'channel_id');\n * await channel.watch();\n *\n * <Chat client={client}>\n * <Channel channel={channel}>\n * </Channel>\n * </Chat>\n * ```\n *\n * @overrideType Channel\n */\n channel: Channel<StreamChatGenerics>;\n /**\n * Custom UI component to display empty state when channel has no messages.\n *\n * **Default** [EmptyStateIndicator](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/Indicators/EmptyStateIndicator.tsx)\n */\n EmptyStateIndicator: React.ComponentType<EmptyStateProps>;\n /**\n * When set to true, reactions will be limited to 1 per user. If user selects another reaction\n * then his previous reaction will be removed and replaced with new one.\n *\n * This is similar to reaction UX on [iMessage application](https://en.wikipedia.org/wiki/IMessage).\n */\n enforceUniqueReaction: boolean;\n error: boolean | Error;\n /**\n * When set to false, it will disable giphy command on MessageInput component.\n */\n giphyEnabled: boolean;\n /**\n * Hide inline date separators on channel\n */\n hideDateSeparators: boolean;\n hideStickyDateHeader: boolean;\n /**\n * Returns true if the current user has admin privileges\n */\n isAdmin: boolean;\n /**\n * Returns true if the current user is a moderator\n */\n isModerator: boolean;\n /**\n * Returns true if the current user is a owner\n */\n isOwner: boolean;\n /**\n * Loads channel around a specific message\n *\n * @param messageId If undefined, channel will be loaded at most recent message.\n */\n loadChannelAroundMessage: ({ messageId }: { messageId?: string }) => Promise<void>;\n /**\n * @deprecated use loadChannelAroundMessage instead\n *\n * Loads channel at specific message\n *\n * @param messageId If undefined, channel will be loaded at most recent message.\n * @param before Number of message to query before messageId\n * @param after Number of message to query after messageId\n */\n loadChannelAtMessage: ({\n after,\n before,\n messageId,\n }: {\n after?: number;\n before?: number;\n messageId?: string;\n }) => Promise<void>;\n loading: boolean;\n /**\n * Custom loading indicator to override the Stream default\n */\n LoadingIndicator: React.ComponentType<LoadingProps>;\n markRead: () => void;\n /**\n *\n * ```json\n * {\n * \"thierry-123\": {\n * \"id\": \"thierry-123\",\n * \"role\": \"user\",\n * \"created_at\": \"2019-04-03T14:42:47.087869Z\",\n * \"updated_at\": \"2019-04-16T09:20:03.982283Z\",\n * \"last_active\": \"2019-04-16T11:23:51.168113408+02:00\",\n * \"online\": true\n * },\n * \"vishal-123\": {\n * \"id\": \"vishal-123\",\n * \"role\": \"user\",\n * \"created_at\": \"2019-05-03T14:42:47.087869Z\",\n * \"updated_at\": \"2019-05-16T09:20:03.982283Z\",\n * \"last_active\": \"2019-06-16T11:23:51.168113408+02:00\",\n * \"online\": false\n * }\n * }\n * ```\n */\n members: ChannelState<StreamChatGenerics>['members'];\n /**\n * Custom network down indicator to override the Stream default\n */\n NetworkDownIndicator: React.ComponentType;\n read: ChannelState<StreamChatGenerics>['read'];\n reloadChannel: () => Promise<void>;\n /**\n * When true, messagelist will be scrolled to first unread message, when opened.\n */\n scrollToFirstUnreadThreshold: number;\n setLastRead: React.Dispatch<React.SetStateAction<Date | undefined>>;\n setTargetedMessage: (messageId: string) => void;\n /**\n * Abort controller for cancelling async requests made for uploading images/files\n * Its a map of filename and AbortController\n */\n uploadAbortControllerRef: React.MutableRefObject<Map<string, AbortController>>;\n /**\n *\n * ```json\n * {\n * \"thierry-123\": {\n * \"id\": \"thierry-123\",\n * \"role\": \"user\",\n * \"created_at\": \"2019-04-03T14:42:47.087869Z\",\n * \"updated_at\": \"2019-04-16T09:20:03.982283Z\",\n * \"last_active\": \"2019-04-16T11:23:51.168113408+02:00\",\n * \"online\": true\n * },\n * \"vishal-123\": {\n * \"id\": \"vishal-123\",\n * \"role\": \"user\",\n * \"created_at\": \"2019-05-03T14:42:47.087869Z\",\n * \"updated_at\": \"2019-05-16T09:20:03.982283Z\",\n * \"last_active\": \"2019-06-16T11:23:51.168113408+02:00\",\n * \"online\": false\n * }\n * }\n * ```\n */\n watchers: ChannelState<StreamChatGenerics>['watchers'];\n disabled?: boolean;\n enableMessageGroupingByUser?: boolean;\n isChannelActive?: boolean;\n lastRead?: Date;\n /**\n * Maximum time in milliseconds that should occur between messages\n * to still consider them grouped together\n */\n maxTimeBetweenGroupedMessages?: number;\n /**\n * Custom UI component for sticky header of channel.\n *\n * **Default** [DateHeader](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/MessageList/DateHeader.tsx)\n */\n StickyHeader?: React.ComponentType<{ dateString: string }>;\n /**\n * Id of message, around which Channel/MessageList gets loaded when opened.\n * You will see a highlighted background for targetted message, when opened.\n */\n targetedMessage?: string;\n threadList?: boolean;\n watcherCount?: ChannelState<StreamChatGenerics>['watcher_count'];\n};\n\nexport const ChannelContext = React.createContext(\n DEFAULT_BASE_CONTEXT_VALUE as ChannelContextValue,\n);\n\nexport const ChannelProvider = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n children,\n value,\n}: PropsWithChildren<{\n value: ChannelContextValue<StreamChatGenerics>;\n}>) => (\n <ChannelContext.Provider value={value as unknown as ChannelContextValue}>\n {children}\n </ChannelContext.Provider>\n);\n\nexport const useChannelContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>() => {\n const contextValue = useContext(\n ChannelContext,\n ) as unknown as ChannelContextValue<StreamChatGenerics>;\n\n if (contextValue === DEFAULT_BASE_CONTEXT_VALUE && !isTestEnvironment()) {\n throw new Error(\n `The useChannelContext hook was called outside of the ChannelContext provider. Make sure you have configured Channel component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#channel`,\n );\n }\n\n return contextValue;\n};\n/**\n * Typescript currently does not support partial inference so if ChatContext\n * typing is desired while using the HOC withChannelContext the Props for the\n * wrapped component must be provided as the first generic.\n */\nexport const withChannelContext = <\n P extends UnknownType,\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n Component: React.ComponentType<P>,\n): React.FC<Omit<P, keyof ChannelContextValue<StreamChatGenerics>>> => {\n const WithChannelContextComponent = (\n props: Omit<P, keyof ChannelContextValue<StreamChatGenerics>>,\n ) => {\n const channelContext = useChannelContext<StreamChatGenerics>();\n\n return <Component {...(props as P)} {...channelContext} />;\n };\n WithChannelContextComponent.displayName = `WithChannelContext${getDisplayName(Component)}`;\n return WithChannelContextComponent;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,wBAAA,GAAAD,OAAA;AAEA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AAA+D,IAAAI,KAAA;EAAAC,YAAA;AAAA,SAAAC,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAR,wBAAAY,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,aAAAE,OAAA,CAAAF,GAAA,yBAAAA,GAAA,uCAAAA,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA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,YAAAuC,aAAA,CAACa,SAAS,MAAAI,SAAA,iBAAMF,KAAK,EAAYC,cAAc;MAAAd,MAAA,EAAAnC,KAAA;MAAAoC,QAAA;QAAAC,QAAA,EAAApC,YAAA;QAAAqC,UAAA;QAAAC,YAAA;MAAA;IAAA,EAAG,CAAC;EAC5D,CAAC;EACDQ,2BAA2B,CAACI,WAAW,0BAAwB,IAAAC,8BAAc,EAACN,SAAS,CAAG;EAC1F,OAAOC,2BAA2B;AACpC,CAAC;AAACnB,OAAA,CAAAiB,kBAAA,GAAAA,kBAAA"}
|
|
@@ -19,6 +19,7 @@ var _useCreateMessageInputContext = require("./hooks/useCreateMessageInputContex
|
|
|
19
19
|
var _useMessageDetailsForState = require("./hooks/useMessageDetailsForState");
|
|
20
20
|
var _useCooldown2 = require("../../components/MessageInput/hooks/useCooldown");
|
|
21
21
|
var _native = require("../../native");
|
|
22
|
+
var _compressImage = require("../../utils/compressImage");
|
|
22
23
|
var _removeReservedFields = require("../../utils/removeReservedFields");
|
|
23
24
|
var _utils = require("../../utils/utils");
|
|
24
25
|
var _AttachmentPickerContext = require("../attachmentPickerContext/AttachmentPickerContext");
|
|
@@ -76,7 +77,8 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
|
|
|
76
77
|
var channelCapabities = (0, _OwnCapabilitiesContext.useOwnCapabilitiesContext)();
|
|
77
78
|
var _useChannelContext = (0, _ChannelContext.useChannelContext)(),
|
|
78
79
|
channel = _useChannelContext.channel,
|
|
79
|
-
giphyEnabled = _useChannelContext.giphyEnabled
|
|
80
|
+
giphyEnabled = _useChannelContext.giphyEnabled,
|
|
81
|
+
uploadAbortControllerRef = _useChannelContext.uploadAbortControllerRef;
|
|
80
82
|
var _useThreadContext = (0, _ThreadContext.useThreadContext)(),
|
|
81
83
|
thread = _useThreadContext.thread;
|
|
82
84
|
var _useTranslationContex = (0, _TranslationContext.useTranslationContext)(),
|
|
@@ -298,13 +300,14 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
|
|
|
298
300
|
};
|
|
299
301
|
var mapImageUploadToAttachment = function mapImageUploadToAttachment(image) {
|
|
300
302
|
var mime_type = (0, _mimeTypes.lookup)(image.file.name);
|
|
303
|
+
var name = image.file.name;
|
|
301
304
|
return {
|
|
302
|
-
fallback:
|
|
305
|
+
fallback: name,
|
|
303
306
|
image_url: image.url,
|
|
304
307
|
mime_type: mime_type ? mime_type : undefined,
|
|
305
308
|
original_height: image.height,
|
|
306
309
|
original_width: image.width,
|
|
307
|
-
|
|
310
|
+
originalImage: image.file,
|
|
308
311
|
type: 'image'
|
|
309
312
|
};
|
|
310
313
|
};
|
|
@@ -697,34 +700,43 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
|
|
|
697
700
|
return value.doDocUploadRequest(file, channel);
|
|
698
701
|
case 8:
|
|
699
702
|
response = _context5.sent;
|
|
700
|
-
_context5.next =
|
|
703
|
+
_context5.next = 17;
|
|
701
704
|
break;
|
|
702
705
|
case 11:
|
|
703
706
|
if (!(channel && file.uri)) {
|
|
704
|
-
_context5.next =
|
|
707
|
+
_context5.next = 17;
|
|
705
708
|
break;
|
|
706
709
|
}
|
|
707
|
-
|
|
710
|
+
uploadAbortControllerRef.current.set(file.name, client.createAbortControllerForNextRequest());
|
|
711
|
+
_context5.next = 15;
|
|
708
712
|
return channel.sendFile(file.uri, file.name, file.mimeType);
|
|
709
|
-
case 14:
|
|
710
|
-
response = _context5.sent;
|
|
711
713
|
case 15:
|
|
714
|
+
response = _context5.sent;
|
|
715
|
+
uploadAbortControllerRef.current["delete"](file.name);
|
|
716
|
+
case 17:
|
|
712
717
|
extraData = {
|
|
713
718
|
thumb_url: response.thumb_url,
|
|
714
719
|
url: response.file
|
|
715
720
|
};
|
|
716
721
|
setFileUploads(getUploadSetStateAction(id, _utils.FileState.UPLOADED, extraData));
|
|
717
|
-
_context5.next =
|
|
722
|
+
_context5.next = 27;
|
|
718
723
|
break;
|
|
719
|
-
case
|
|
720
|
-
_context5.prev =
|
|
724
|
+
case 21:
|
|
725
|
+
_context5.prev = 21;
|
|
721
726
|
_context5.t0 = _context5["catch"](4);
|
|
727
|
+
if (!(_context5.t0 instanceof Error && (_context5.t0.name === 'AbortError' || _context5.t0.name === 'CanceledError'))) {
|
|
728
|
+
_context5.next = 26;
|
|
729
|
+
break;
|
|
730
|
+
}
|
|
731
|
+
uploadAbortControllerRef.current["delete"](file.name);
|
|
732
|
+
return _context5.abrupt("return");
|
|
733
|
+
case 26:
|
|
722
734
|
handleFileOrImageUploadError(_context5.t0, false, id);
|
|
723
|
-
case
|
|
735
|
+
case 27:
|
|
724
736
|
case "end":
|
|
725
737
|
return _context5.stop();
|
|
726
738
|
}
|
|
727
|
-
}, _callee5, null, [[4,
|
|
739
|
+
}, _callee5, null, [[4, 21]]);
|
|
728
740
|
}));
|
|
729
741
|
return function uploadFile(_x) {
|
|
730
742
|
return _ref6.apply(this, arguments);
|
|
@@ -732,7 +744,8 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
|
|
|
732
744
|
}();
|
|
733
745
|
var uploadImage = function () {
|
|
734
746
|
var _ref8 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee6(_ref7) {
|
|
735
|
-
var
|
|
747
|
+
var _file$name;
|
|
748
|
+
var newImage, _ref9, file, id, response, uri, filename, compressedUri, contentType, newImageUploads;
|
|
736
749
|
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
737
750
|
while (1) switch (_context6.prev = _context6.next) {
|
|
738
751
|
case 0:
|
|
@@ -745,18 +758,13 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
|
|
|
745
758
|
return _context6.abrupt("return");
|
|
746
759
|
case 4:
|
|
747
760
|
response = {};
|
|
748
|
-
_context6.prev = 5;
|
|
749
761
|
uri = file.uri || '';
|
|
750
|
-
_context6.next = 9;
|
|
751
|
-
return file.source === 'camera' || !file.height || !file.width || typeof value.compressImageQuality !== 'number' || value.compressImageQuality === 1 ? uri : (0, _native.compressImage)({
|
|
752
|
-
compressImageQuality: value.compressImageQuality,
|
|
753
|
-
height: file.height,
|
|
754
|
-
uri: uri,
|
|
755
|
-
width: file.width
|
|
756
|
-
});
|
|
757
|
-
case 9:
|
|
758
|
-
compressedUri = _context6.sent;
|
|
759
762
|
filename = (_file$name = file.name) != null ? _file$name : uri.replace(/^(file:\/\/|content:\/\/)/, '');
|
|
763
|
+
_context6.prev = 7;
|
|
764
|
+
_context6.next = 10;
|
|
765
|
+
return (0, _compressImage.compressedImageURI)(file, value.compressImageQuality);
|
|
766
|
+
case 10:
|
|
767
|
+
compressedUri = _context6.sent;
|
|
760
768
|
contentType = (0, _mimeTypes.lookup)(filename) || 'multipart/form-data';
|
|
761
769
|
if (!value.doImageUploadRequest) {
|
|
762
770
|
_context6.next = 18;
|
|
@@ -766,18 +774,20 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
|
|
|
766
774
|
return value.doImageUploadRequest(file, channel);
|
|
767
775
|
case 15:
|
|
768
776
|
response = _context6.sent;
|
|
769
|
-
_context6.next =
|
|
777
|
+
_context6.next = 29;
|
|
770
778
|
break;
|
|
771
779
|
case 18:
|
|
772
780
|
if (!(compressedUri && channel)) {
|
|
773
|
-
_context6.next =
|
|
781
|
+
_context6.next = 29;
|
|
774
782
|
break;
|
|
775
783
|
}
|
|
776
784
|
if (!value.sendImageAsync) {
|
|
777
|
-
_context6.next =
|
|
785
|
+
_context6.next = 24;
|
|
778
786
|
break;
|
|
779
787
|
}
|
|
788
|
+
uploadAbortControllerRef.current.set(filename, client.createAbortControllerForNextRequest());
|
|
780
789
|
channel.sendImage(compressedUri, filename, contentType).then(function (res) {
|
|
790
|
+
uploadAbortControllerRef.current["delete"](filename);
|
|
781
791
|
if (asyncIds.includes(id)) {
|
|
782
792
|
setAsyncUploads(function (prevAsyncUploads) {
|
|
783
793
|
prevAsyncUploads[id] = (0, _extends2["default"])({}, prevAsyncUploads[id], {
|
|
@@ -792,15 +802,19 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
|
|
|
792
802
|
});
|
|
793
803
|
setImageUploads(newImageUploads);
|
|
794
804
|
}
|
|
805
|
+
}, function () {
|
|
806
|
+
uploadAbortControllerRef.current["delete"](filename);
|
|
795
807
|
});
|
|
796
|
-
_context6.next =
|
|
808
|
+
_context6.next = 29;
|
|
797
809
|
break;
|
|
798
|
-
case
|
|
799
|
-
|
|
810
|
+
case 24:
|
|
811
|
+
uploadAbortControllerRef.current.set(filename, client.createAbortControllerForNextRequest());
|
|
812
|
+
_context6.next = 27;
|
|
800
813
|
return channel.sendImage(compressedUri, filename, contentType);
|
|
801
|
-
case
|
|
814
|
+
case 27:
|
|
802
815
|
response = _context6.sent;
|
|
803
|
-
|
|
816
|
+
uploadAbortControllerRef.current["delete"](filename);
|
|
817
|
+
case 29:
|
|
804
818
|
if (Object.keys(response).length) {
|
|
805
819
|
newImageUploads = getUploadSetStateAction(id, _utils.FileState.UPLOADED, {
|
|
806
820
|
height: file.height,
|
|
@@ -809,17 +823,24 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
|
|
|
809
823
|
});
|
|
810
824
|
setImageUploads(newImageUploads);
|
|
811
825
|
}
|
|
812
|
-
_context6.next =
|
|
826
|
+
_context6.next = 38;
|
|
813
827
|
break;
|
|
814
|
-
case 29:
|
|
815
|
-
_context6.prev = 29;
|
|
816
|
-
_context6.t0 = _context6["catch"](5);
|
|
817
|
-
handleFileOrImageUploadError(_context6.t0, true, id);
|
|
818
828
|
case 32:
|
|
829
|
+
_context6.prev = 32;
|
|
830
|
+
_context6.t0 = _context6["catch"](7);
|
|
831
|
+
if (!(_context6.t0 instanceof Error && (_context6.t0.name === 'AbortError' || _context6.t0.name === 'CanceledError'))) {
|
|
832
|
+
_context6.next = 37;
|
|
833
|
+
break;
|
|
834
|
+
}
|
|
835
|
+
uploadAbortControllerRef.current["delete"](filename);
|
|
836
|
+
return _context6.abrupt("return");
|
|
837
|
+
case 37:
|
|
838
|
+
handleFileOrImageUploadError(_context6.t0, true, id);
|
|
839
|
+
case 38:
|
|
819
840
|
case "end":
|
|
820
841
|
return _context6.stop();
|
|
821
842
|
}
|
|
822
|
-
}, _callee6, null, [[
|
|
843
|
+
}, _callee6, null, [[7, 32]]);
|
|
823
844
|
}));
|
|
824
845
|
return function uploadImage(_x2) {
|
|
825
846
|
return _ref8.apply(this, arguments);
|
|
@@ -973,7 +994,7 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
|
|
|
973
994
|
__self: _this,
|
|
974
995
|
__source: {
|
|
975
996
|
fileName: _jsxFileName,
|
|
976
|
-
lineNumber:
|
|
997
|
+
lineNumber: 1185,
|
|
977
998
|
columnNumber: 5
|
|
978
999
|
}
|
|
979
1000
|
}, children);
|
|
@@ -994,7 +1015,7 @@ var withMessageInputContext = function withMessageInputContext(Component) {
|
|
|
994
1015
|
__self: _this,
|
|
995
1016
|
__source: {
|
|
996
1017
|
fileName: _jsxFileName,
|
|
997
|
-
lineNumber:
|
|
1018
|
+
lineNumber: 1225,
|
|
998
1019
|
columnNumber: 12
|
|
999
1020
|
}
|
|
1000
1021
|
}));
|