stream-chat-react-native-core 5.0.0-offline-support.12 → 5.0.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/{MessageInput/AudioAttachmentUploadPreview.js → Attachment/AudioAttachment.js} +38 -64
- package/lib/commonjs/components/Attachment/AudioAttachment.js.map +1 -0
- package/lib/commonjs/components/Attachment/Card.js +1 -0
- package/lib/commonjs/components/Attachment/Card.js.map +1 -1
- package/lib/commonjs/components/Attachment/FileAttachment.js +16 -7
- package/lib/commonjs/components/Attachment/FileAttachment.js.map +1 -1
- package/lib/commonjs/components/Attachment/FileAttachmentGroup.js +132 -12
- package/lib/commonjs/components/Attachment/FileAttachmentGroup.js.map +1 -1
- package/lib/commonjs/components/Attachment/Gallery.js +41 -35
- package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
- package/lib/commonjs/components/Attachment/Giphy.js +17 -13
- package/lib/commonjs/components/Attachment/Giphy.js.map +1 -1
- package/lib/commonjs/components/Attachment/VideoThumbnail.js +12 -6
- package/lib/commonjs/components/Attachment/VideoThumbnail.js.map +1 -1
- package/lib/commonjs/components/Attachment/utils/getGiphyMimeType.js +15 -0
- package/lib/commonjs/components/Attachment/utils/getGiphyMimeType.js.map +1 -0
- package/lib/commonjs/components/Channel/Channel.js +19 -19
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js +0 -2
- package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js +2 -0
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessage.js +16 -4
- package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessage.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/usePaginatedChannels.js +12 -7
- package/lib/commonjs/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/ChannelPreview.js +10 -6
- package/lib/commonjs/components/ChannelPreview/ChannelPreview.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +38 -30
- package/lib/commonjs/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js +11 -10
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGrid.js +2 -2
- package/lib/commonjs/components/ImageGallery/components/ImageGrid.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/hooks/useImageGalleryGestures.js +6 -0
- package/lib/commonjs/components/ImageGallery/hooks/useImageGalleryGestures.js.map +1 -1
- package/lib/commonjs/components/Message/Message.js +7 -7
- package/lib/commonjs/components/Message/Message.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageTextContainer.js +7 -3
- package/lib/commonjs/components/Message/MessageSimple/MessageTextContainer.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/utils/parseLinks.js +1 -1
- package/lib/commonjs/components/Message/MessageSimple/utils/parseLinks.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/utils/parseLinks.test.js +1 -1
- package/lib/commonjs/components/Message/MessageSimple/utils/parseLinks.test.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/utils/renderText.js +1 -1
- package/lib/commonjs/components/Message/MessageSimple/utils/renderText.js.map +1 -1
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js +38 -44
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/commonjs/components/MessageList/MessageList.js +5 -5
- package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
- package/lib/commonjs/components/MessageOverlay/MessageOverlay.js +10 -9
- package/lib/commonjs/components/MessageOverlay/MessageOverlay.js.map +1 -1
- package/lib/commonjs/components/index.js +13 -13
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/contexts/imageGalleryContext/ImageGalleryContext.js +13 -14
- package/lib/commonjs/contexts/imageGalleryContext/ImageGalleryContext.js.map +1 -1
- package/lib/commonjs/contexts/imageGalleryContext/ImageGalleryContext.md +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +2 -2
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +0 -2
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js +2 -2
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/commonjs/contexts/themeContext/utils/theme.js +2 -2
- package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/commonjs/index.js +13 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mock-builders/DB/mock.js +1 -13
- package/lib/commonjs/mock-builders/DB/mock.js.map +1 -1
- package/lib/commonjs/mock-builders/event/messageNew.js +2 -0
- package/lib/commonjs/mock-builders/event/messageNew.js.map +1 -1
- package/lib/commonjs/store/QuickSqliteClient.js +7 -3
- package/lib/commonjs/store/QuickSqliteClient.js.map +1 -1
- package/lib/commonjs/store/apis/getChannels.js +2 -15
- package/lib/commonjs/store/apis/getChannels.js.map +1 -1
- package/lib/commonjs/store/apis/getChannelsForFilterSort.js +37 -0
- package/lib/commonjs/store/apis/getChannelsForFilterSort.js.map +1 -0
- package/lib/commonjs/store/apis/index.js +264 -0
- package/lib/commonjs/store/apis/index.js.map +1 -0
- package/lib/commonjs/store/apis/queries/selectChannelIdsForFilterSort.js +1 -1
- package/lib/commonjs/store/apis/queries/selectChannelIdsForFilterSort.js.map +1 -1
- package/lib/commonjs/store/apis/queries/selectChannels.js +2 -2
- package/lib/commonjs/store/apis/queries/selectChannels.js.map +1 -1
- package/lib/commonjs/store/sqlite-utils/appendWhereCluase.js +1 -2
- package/lib/commonjs/store/sqlite-utils/appendWhereCluase.js.map +1 -1
- package/lib/commonjs/test-utils/BetterSqlite.js +54 -0
- package/lib/commonjs/test-utils/BetterSqlite.js.map +1 -0
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/{MessageInput/AudioAttachmentUploadPreview.js → Attachment/AudioAttachment.js} +38 -64
- package/lib/module/components/Attachment/AudioAttachment.js.map +1 -0
- package/lib/module/components/Attachment/Card.js +1 -0
- package/lib/module/components/Attachment/Card.js.map +1 -1
- package/lib/module/components/Attachment/FileAttachment.js +16 -7
- package/lib/module/components/Attachment/FileAttachment.js.map +1 -1
- package/lib/module/components/Attachment/FileAttachmentGroup.js +132 -12
- package/lib/module/components/Attachment/FileAttachmentGroup.js.map +1 -1
- package/lib/module/components/Attachment/Gallery.js +41 -35
- package/lib/module/components/Attachment/Gallery.js.map +1 -1
- package/lib/module/components/Attachment/Giphy.js +17 -13
- package/lib/module/components/Attachment/Giphy.js.map +1 -1
- package/lib/module/components/Attachment/VideoThumbnail.js +12 -6
- package/lib/module/components/Attachment/VideoThumbnail.js.map +1 -1
- package/lib/module/components/Attachment/utils/getGiphyMimeType.js +15 -0
- package/lib/module/components/Attachment/utils/getGiphyMimeType.js.map +1 -0
- package/lib/module/components/Channel/Channel.js +19 -19
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js +0 -2
- package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js +2 -0
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/listeners/useNewMessage.js +16 -4
- package/lib/module/components/ChannelList/hooks/listeners/useNewMessage.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/usePaginatedChannels.js +12 -7
- package/lib/module/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
- package/lib/module/components/ChannelPreview/ChannelPreview.js +10 -6
- package/lib/module/components/ChannelPreview/ChannelPreview.js.map +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +38 -30
- package/lib/module/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js +11 -10
- package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ImageGrid.js +2 -2
- package/lib/module/components/ImageGallery/components/ImageGrid.js.map +1 -1
- package/lib/module/components/ImageGallery/hooks/useImageGalleryGestures.js +6 -0
- package/lib/module/components/ImageGallery/hooks/useImageGalleryGestures.js.map +1 -1
- package/lib/module/components/Message/Message.js +7 -7
- package/lib/module/components/Message/Message.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageTextContainer.js +7 -3
- package/lib/module/components/Message/MessageSimple/MessageTextContainer.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/utils/parseLinks.js +1 -1
- package/lib/module/components/Message/MessageSimple/utils/parseLinks.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/utils/parseLinks.test.js +1 -1
- package/lib/module/components/Message/MessageSimple/utils/parseLinks.test.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/utils/renderText.js +1 -1
- package/lib/module/components/Message/MessageSimple/utils/renderText.js.map +1 -1
- package/lib/module/components/MessageInput/FileUploadPreview.js +38 -44
- package/lib/module/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/module/components/MessageList/MessageList.js +5 -5
- package/lib/module/components/MessageList/MessageList.js.map +1 -1
- package/lib/module/components/MessageOverlay/MessageOverlay.js +10 -9
- package/lib/module/components/MessageOverlay/MessageOverlay.js.map +1 -1
- package/lib/module/components/index.js +13 -13
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/contexts/imageGalleryContext/ImageGalleryContext.js +13 -14
- package/lib/module/contexts/imageGalleryContext/ImageGalleryContext.js.map +1 -1
- package/lib/module/contexts/imageGalleryContext/ImageGalleryContext.md +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +2 -2
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +0 -2
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
- package/lib/module/contexts/messagesContext/MessagesContext.js +2 -2
- package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/module/contexts/themeContext/utils/theme.js +2 -2
- package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/module/index.js +13 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/mock-builders/DB/mock.js +1 -13
- package/lib/module/mock-builders/DB/mock.js.map +1 -1
- package/lib/module/mock-builders/event/messageNew.js +2 -0
- package/lib/module/mock-builders/event/messageNew.js.map +1 -1
- package/lib/module/store/QuickSqliteClient.js +7 -3
- package/lib/module/store/QuickSqliteClient.js.map +1 -1
- package/lib/module/store/apis/getChannels.js +2 -15
- package/lib/module/store/apis/getChannels.js.map +1 -1
- package/lib/module/store/apis/getChannelsForFilterSort.js +37 -0
- package/lib/module/store/apis/getChannelsForFilterSort.js.map +1 -0
- package/lib/module/store/apis/index.js +264 -0
- package/lib/module/store/apis/index.js.map +1 -0
- package/lib/module/store/apis/queries/selectChannelIdsForFilterSort.js +1 -1
- package/lib/module/store/apis/queries/selectChannelIdsForFilterSort.js.map +1 -1
- package/lib/module/store/apis/queries/selectChannels.js +2 -2
- package/lib/module/store/apis/queries/selectChannels.js.map +1 -1
- package/lib/module/store/sqlite-utils/appendWhereCluase.js +1 -2
- package/lib/module/store/sqlite-utils/appendWhereCluase.js.map +1 -1
- package/lib/module/test-utils/BetterSqlite.js +54 -0
- package/lib/module/test-utils/BetterSqlite.js.map +1 -0
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Attachment/AudioAttachment.d.ts +23 -0
- package/lib/typescript/components/Attachment/FileAttachmentGroup.d.ts +1 -1
- package/lib/typescript/components/Attachment/Gallery.d.ts +1 -1
- package/lib/typescript/components/Attachment/Giphy.d.ts +1 -1
- package/lib/typescript/components/Attachment/utils/getGiphyMimeType.d.ts +6 -0
- package/lib/typescript/components/Channel/Channel.d.ts +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateInputMessageInputContext.d.ts +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts +1 -1
- package/lib/typescript/components/ImageGallery/components/ImageGrid.d.ts +1 -1
- package/lib/typescript/components/ImageGallery/hooks/useImageGalleryGestures.d.ts +2 -1
- package/lib/typescript/components/Message/Message.d.ts +9 -3
- package/lib/typescript/components/MessageInput/FileUploadPreview.d.ts +1 -1
- package/lib/typescript/components/MessageList/MessageList.d.ts +1 -1
- package/lib/typescript/components/index.d.ts +1 -1
- package/lib/typescript/contexts/imageGalleryContext/ImageGalleryContext.d.ts +9 -10
- package/lib/typescript/contexts/messageContext/MessageContext.d.ts +1 -1
- package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +1 -4
- package/lib/typescript/contexts/messageInputContext/hooks/useCreateMessageInputContext.d.ts +1 -1
- package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +3 -0
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts +2 -2
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/store/QuickSqliteClient.d.ts +4 -0
- package/lib/typescript/store/apis/getChannels.d.ts +13 -5
- package/lib/typescript/store/apis/getChannelsForFilterSort.d.ts +17 -0
- package/lib/typescript/store/apis/index.d.ts +20 -0
- package/lib/typescript/store/apis/queries/selectChannelIdsForFilterSort.d.ts +10 -1
- package/lib/typescript/{__tests__/utils → test-utils}/BetterSqlite.d.ts +1 -1
- package/package.json +5 -4
- package/src/__tests__/offline-feature.test.js +1 -2
- package/src/components/{MessageInput/AudioAttachmentUploadPreview.tsx → Attachment/AudioAttachment.tsx} +82 -131
- package/src/components/Attachment/Card.tsx +1 -0
- package/src/components/Attachment/FileAttachment.tsx +3 -0
- package/src/components/Attachment/FileAttachmentGroup.tsx +119 -9
- package/src/components/Attachment/Gallery.tsx +30 -19
- package/src/components/Attachment/Giphy.tsx +15 -8
- package/src/components/Attachment/VideoThumbnail.tsx +3 -2
- package/src/components/Attachment/utils/getGiphyMimeType.ts +13 -0
- package/src/components/Channel/Channel.tsx +5 -4
- package/src/components/Channel/hooks/useCreateInputMessageInputContext.ts +0 -2
- package/src/components/Channel/hooks/useCreateMessagesContext.ts +2 -0
- package/src/components/ChannelList/__tests__/ChannelList.test.js +28 -0
- package/src/components/ChannelList/hooks/listeners/useNewMessage.ts +18 -5
- package/src/components/ChannelList/hooks/usePaginatedChannels.ts +19 -10
- package/src/components/ChannelPreview/ChannelPreview.tsx +6 -3
- package/src/components/ImageGallery/ImageGallery.tsx +32 -19
- package/src/components/ImageGallery/__tests__/ImageGallery.test.tsx +6 -6
- package/src/components/ImageGallery/__tests__/ImageGalleryFooter.test.tsx +3 -3
- package/src/components/ImageGallery/__tests__/ImageGalleryGrid.test.tsx +3 -3
- package/src/components/ImageGallery/__tests__/ImageGalleryHeader.test.tsx +3 -3
- package/src/components/ImageGallery/components/ImageGalleryVideoControl.tsx +12 -7
- package/src/components/ImageGallery/components/ImageGrid.tsx +3 -3
- package/src/components/ImageGallery/hooks/useImageGalleryGestures.tsx +16 -0
- package/src/components/Message/Message.tsx +10 -2
- package/src/components/Message/MessageSimple/MessageTextContainer.tsx +22 -2
- package/src/components/Message/MessageSimple/__tests__/MessageContent.test.js +4 -2
- package/src/components/Message/MessageSimple/__tests__/__snapshots__/MessageAvatar.test.js.snap +1 -0
- package/src/components/Message/MessageSimple/utils/parseLinks.test.ts +4 -0
- package/src/components/Message/MessageSimple/utils/parseLinks.ts +1 -1
- package/src/components/Message/MessageSimple/utils/renderText.tsx +1 -1
- package/src/components/MessageInput/FileUploadPreview.tsx +34 -26
- package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewExpo.test.tsx +15 -8
- package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewNative.test.tsx +15 -8
- package/src/components/MessageInput/__tests__/FileUploadPreview.test.js +5 -5
- package/src/components/MessageList/MessageList.tsx +6 -6
- package/src/components/MessageOverlay/MessageOverlay.tsx +1 -0
- package/src/components/Thread/__tests__/__snapshots__/Thread.test.js.snap +4 -0
- package/src/components/index.ts +1 -1
- package/src/contexts/imageGalleryContext/ImageGalleryContext.md +1 -1
- package/src/contexts/imageGalleryContext/ImageGalleryContext.tsx +19 -14
- package/src/contexts/messageInputContext/MessageInputContext.tsx +0 -6
- package/src/contexts/messageInputContext/hooks/useCreateMessageInputContext.ts +0 -2
- package/src/contexts/messagesContext/MessagesContext.tsx +3 -0
- package/src/contexts/themeContext/utils/theme.ts +4 -4
- package/src/index.ts +3 -0
- package/src/mock-builders/DB/mock.ts +4 -9
- package/src/mock-builders/event/messageNew.js +2 -0
- package/src/store/QuickSqliteClient.ts +11 -7
- package/src/store/apis/getChannels.ts +17 -14
- package/src/store/apis/getChannelsForFilterSort.ts +45 -0
- package/src/store/apis/index.ts +20 -0
- package/src/store/apis/queries/selectChannelIdsForFilterSort.ts +12 -2
- package/src/store/apis/queries/selectChannels.ts +9 -3
- package/src/store/sqlite-utils/appendWhereCluase.ts +1 -2
- package/src/{__tests__/utils → test-utils}/BetterSqlite.js +1 -1
- package/src/version.json +1 -1
- package/lib/commonjs/components/MessageInput/AudioAttachmentUploadPreview.js.map +0 -1
- package/lib/module/components/MessageInput/AudioAttachmentUploadPreview.js.map +0 -1
- package/lib/typescript/components/MessageInput/AudioAttachmentUploadPreview.d.ts +0 -26
|
@@ -107,7 +107,7 @@ export type ImageGridType<
|
|
|
107
107
|
> = ImageGalleryGridImageComponents<StreamChatGenerics> & {
|
|
108
108
|
closeGridView: () => void;
|
|
109
109
|
photos: Photo<StreamChatGenerics>[];
|
|
110
|
-
|
|
110
|
+
setSelectedMessage: React.Dispatch<
|
|
111
111
|
React.SetStateAction<
|
|
112
112
|
| {
|
|
113
113
|
messageId?: string | undefined;
|
|
@@ -130,7 +130,7 @@ export const ImageGrid = <
|
|
|
130
130
|
imageComponent,
|
|
131
131
|
numberOfImageGalleryGridColumns,
|
|
132
132
|
photos,
|
|
133
|
-
|
|
133
|
+
setSelectedMessage,
|
|
134
134
|
} = props;
|
|
135
135
|
|
|
136
136
|
const {
|
|
@@ -148,7 +148,7 @@ export const ImageGrid = <
|
|
|
148
148
|
imageComponent,
|
|
149
149
|
numberOfImageGalleryGridColumns,
|
|
150
150
|
selectAndClose: () => {
|
|
151
|
-
|
|
151
|
+
setSelectedMessage({ messageId: photo.messageId, url: photo.uri });
|
|
152
152
|
closeGridView();
|
|
153
153
|
},
|
|
154
154
|
}));
|
|
@@ -42,6 +42,7 @@ export const useImageGalleryGestures = ({
|
|
|
42
42
|
scale,
|
|
43
43
|
screenHeight,
|
|
44
44
|
screenWidth,
|
|
45
|
+
selectedIndex,
|
|
45
46
|
setSelectedIndex,
|
|
46
47
|
translateX,
|
|
47
48
|
translateY,
|
|
@@ -57,6 +58,7 @@ export const useImageGalleryGestures = ({
|
|
|
57
58
|
scale: SharedValue<number>;
|
|
58
59
|
screenHeight: number;
|
|
59
60
|
screenWidth: number;
|
|
61
|
+
selectedIndex: number;
|
|
60
62
|
setSelectedIndex: React.Dispatch<React.SetStateAction<number>>;
|
|
61
63
|
translateX: SharedValue<number>;
|
|
62
64
|
translateY: SharedValue<number>;
|
|
@@ -82,6 +84,20 @@ export const useImageGalleryGestures = ({
|
|
|
82
84
|
const focalY = useSharedValue(0);
|
|
83
85
|
const index = useSharedValue(0);
|
|
84
86
|
|
|
87
|
+
/**
|
|
88
|
+
* if a specific image index > 0 has been passed in
|
|
89
|
+
* while creating the hook, set the value of the index
|
|
90
|
+
* reference to its value.
|
|
91
|
+
*
|
|
92
|
+
* This makes it possible to seelct an image in the list,
|
|
93
|
+
* and scroll/pan as normal. Prior to this,
|
|
94
|
+
* it was always assumed that one started at index 0 in the
|
|
95
|
+
* gallery.
|
|
96
|
+
* */
|
|
97
|
+
if (index.value !== selectedIndex) {
|
|
98
|
+
index.value = selectedIndex;
|
|
99
|
+
}
|
|
100
|
+
|
|
85
101
|
/**
|
|
86
102
|
* Shared values for movement
|
|
87
103
|
*/
|
|
@@ -73,15 +73,23 @@ export type UrlTouchableHandlerPayload = {
|
|
|
73
73
|
additionalInfo?: { url?: string };
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
+
export type FileAttachmentTouchableHandlerPayload<
|
|
77
|
+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
78
|
+
> = {
|
|
79
|
+
emitter: 'fileAttachment';
|
|
80
|
+
additionalInfo?: { attachment?: Attachment<StreamChatGenerics> };
|
|
81
|
+
};
|
|
82
|
+
|
|
76
83
|
export type TouchableHandlerPayload = {
|
|
77
84
|
defaultHandler?: () => void;
|
|
78
85
|
event?: GestureResponderEvent;
|
|
79
86
|
} & (
|
|
80
87
|
| {
|
|
81
|
-
emitter?: TouchableEmitter
|
|
88
|
+
emitter?: Exclude<TouchableEmitter, 'textMention' | 'textLink' | 'card' | 'fileAttachment'>;
|
|
82
89
|
}
|
|
83
90
|
| TextMentionTouchableHandlerPayload
|
|
84
91
|
| UrlTouchableHandlerPayload
|
|
92
|
+
| FileAttachmentTouchableHandlerPayload
|
|
85
93
|
);
|
|
86
94
|
|
|
87
95
|
export type MessageTouchableHandlerPayload<
|
|
@@ -763,7 +771,7 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
763
771
|
prevMessage.type === nextMessage.type &&
|
|
764
772
|
prevMessage.text === nextMessage.text &&
|
|
765
773
|
prevMessage.pinned === nextMessage.pinned &&
|
|
766
|
-
prevMessage
|
|
774
|
+
`${prevMessage?.updated_at}` === `${nextMessage?.updated_at}`;
|
|
767
775
|
|
|
768
776
|
if (!messageEqual) return false;
|
|
769
777
|
|
|
@@ -117,8 +117,16 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
117
117
|
prevProps: MessageTextContainerPropsWithContext<StreamChatGenerics>,
|
|
118
118
|
nextProps: MessageTextContainerPropsWithContext<StreamChatGenerics>,
|
|
119
119
|
) => {
|
|
120
|
-
const {
|
|
121
|
-
|
|
120
|
+
const {
|
|
121
|
+
markdownStyles: prevMarkdownStyles,
|
|
122
|
+
message: prevMessage,
|
|
123
|
+
onlyEmojis: prevOnlyEmojis,
|
|
124
|
+
} = prevProps;
|
|
125
|
+
const {
|
|
126
|
+
markdownStyles: nextMarkdownStyles,
|
|
127
|
+
message: nextMessage,
|
|
128
|
+
onlyEmojis: nextOnlyEmojis,
|
|
129
|
+
} = nextProps;
|
|
122
130
|
|
|
123
131
|
const messageTextEqual = prevMessage.text === nextMessage.text;
|
|
124
132
|
if (!messageTextEqual) return false;
|
|
@@ -134,6 +142,18 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
134
142
|
prevMessage.mentioned_users[0].name === nextMessage.mentioned_users[0].name));
|
|
135
143
|
if (!mentionedUsersEqual) return false;
|
|
136
144
|
|
|
145
|
+
// stringify could be an expensive operation, so lets rule out the obvious
|
|
146
|
+
// possibilities first such as different object reference or empty objects etc.
|
|
147
|
+
// Also keeping markdown equality check at the last to make sure other less
|
|
148
|
+
// expensive equality checks get executed first and markdown check will be skipped if returned
|
|
149
|
+
// false from previous checks.
|
|
150
|
+
const markdownStylesEqual =
|
|
151
|
+
prevMarkdownStyles === nextMarkdownStyles ||
|
|
152
|
+
(Object.keys(prevMarkdownStyles || {}).length === 0 &&
|
|
153
|
+
Object.keys(nextMarkdownStyles || {}).length === 0) ||
|
|
154
|
+
JSON.stringify(prevMarkdownStyles) === JSON.stringify(nextMarkdownStyles);
|
|
155
|
+
if (!markdownStylesEqual) return false;
|
|
156
|
+
|
|
137
157
|
return true;
|
|
138
158
|
};
|
|
139
159
|
|
|
@@ -196,13 +196,15 @@ describe('MessageContent', () => {
|
|
|
196
196
|
user,
|
|
197
197
|
});
|
|
198
198
|
|
|
199
|
-
const { getByTestId, queryAllByTestId } = renderMessage({ message });
|
|
199
|
+
const { getByTestId, queryAllByA11yLabel, queryAllByTestId } = renderMessage({ message });
|
|
200
200
|
|
|
201
201
|
const fileAttachments = queryAllByTestId('file-attachment');
|
|
202
|
+
const audioAttachments = queryAllByA11yLabel('audio-attachment-preview');
|
|
202
203
|
|
|
203
204
|
await waitFor(() => {
|
|
204
205
|
expect(getByTestId('message-content-wrapper')).toBeTruthy();
|
|
205
|
-
expect(fileAttachments).toHaveLength(
|
|
206
|
+
expect(fileAttachments).toHaveLength(1);
|
|
207
|
+
expect(audioAttachments).toHaveLength(1);
|
|
206
208
|
});
|
|
207
209
|
});
|
|
208
210
|
|
|
@@ -22,6 +22,10 @@ describe('parseLinksFromText', () => {
|
|
|
22
22
|
],
|
|
23
23
|
['127.0.0.1/local_(development)_server', '127.0.0.1/local_(development)_server'],
|
|
24
24
|
['https://a.co:8999/ab.php?p=12', 'a.co:8999/ab.php?p=12'],
|
|
25
|
+
[
|
|
26
|
+
'http://help.apple.com/xcode/mac/current/#/devba7f53ad4',
|
|
27
|
+
'help.apple.com/xcode/mac/current/#/devba7f53ad4',
|
|
28
|
+
],
|
|
25
29
|
])('Returns the encoded value of %p as %p', (link, expected) => {
|
|
26
30
|
const result = parseLinksFromText(link);
|
|
27
31
|
|
|
@@ -11,7 +11,7 @@ const schema = `(\\w{2,15}:\\/\\/)`;
|
|
|
11
11
|
// something.tld OR 123.123.123.123
|
|
12
12
|
const domain = `((?:\\w+\\.[a-zA-Z]+)+(?:[^:\\/\\s]+)|(?:\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}))`;
|
|
13
13
|
const port = `(:[0-9]{1,5})`;
|
|
14
|
-
const path = `((?:\\/)?[
|
|
14
|
+
const path = `((?:\\/)?[^?\\s]+)`;
|
|
15
15
|
const queryString = `(\\?[^#\\s]+)`;
|
|
16
16
|
const fragment = `(#[\\w_-]+)`;
|
|
17
17
|
|
|
@@ -261,7 +261,7 @@ export const renderText = <
|
|
|
261
261
|
);
|
|
262
262
|
|
|
263
263
|
const customRules = {
|
|
264
|
-
link: { link },
|
|
264
|
+
link: { react: link },
|
|
265
265
|
list: { react: list },
|
|
266
266
|
// Truncate long text content in the message overlay
|
|
267
267
|
paragraph: messageTextNumberOfLines ? { react: paragraphText } : {},
|
|
@@ -123,9 +123,9 @@ type FileUploadPreviewPropsWithContext<
|
|
|
123
123
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
124
124
|
> = Pick<
|
|
125
125
|
MessageInputContextValue<StreamChatGenerics>,
|
|
126
|
-
'fileUploads' | 'removeFile' | 'uploadFile' | 'setFileUploads'
|
|
126
|
+
'fileUploads' | 'removeFile' | 'uploadFile' | 'setFileUploads'
|
|
127
127
|
> &
|
|
128
|
-
Pick<MessagesContextValue<StreamChatGenerics>, 'FileAttachmentIcon'>;
|
|
128
|
+
Pick<MessagesContextValue<StreamChatGenerics>, 'AudioAttachment' | 'FileAttachmentIcon'>;
|
|
129
129
|
|
|
130
130
|
const FileUploadPreviewWithContext = <
|
|
131
131
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
@@ -133,7 +133,7 @@ const FileUploadPreviewWithContext = <
|
|
|
133
133
|
props: FileUploadPreviewPropsWithContext<StreamChatGenerics>,
|
|
134
134
|
) => {
|
|
135
135
|
const {
|
|
136
|
-
|
|
136
|
+
AudioAttachment,
|
|
137
137
|
FileAttachmentIcon,
|
|
138
138
|
fileUploads,
|
|
139
139
|
removeFile,
|
|
@@ -172,8 +172,8 @@ const FileUploadPreviewWithContext = <
|
|
|
172
172
|
};
|
|
173
173
|
|
|
174
174
|
// The handler which controls or sets the paused/played state of the audio.
|
|
175
|
-
const onPlayPause = (index: string,
|
|
176
|
-
if (
|
|
175
|
+
const onPlayPause = (index: string, pausedStatus?: boolean) => {
|
|
176
|
+
if (pausedStatus === false) {
|
|
177
177
|
// If the status is false we set the audio with the index as playing and the others as paused.
|
|
178
178
|
setFileUploads((prevFileUploads) =>
|
|
179
179
|
prevFileUploads.map((fileUpload) => ({
|
|
@@ -194,7 +194,7 @@ const FileUploadPreviewWithContext = <
|
|
|
194
194
|
|
|
195
195
|
const {
|
|
196
196
|
theme: {
|
|
197
|
-
colors: { black, grey_dark, grey_gainsboro, grey_whisper },
|
|
197
|
+
colors: { black, grey_dark, grey_gainsboro, grey_whisper, white },
|
|
198
198
|
messageInput: {
|
|
199
199
|
fileUploadPreview: {
|
|
200
200
|
audioAttachmentFileContainer,
|
|
@@ -230,14 +230,31 @@ const FileUploadPreviewWithContext = <
|
|
|
230
230
|
audioAttachmentFileContainer,
|
|
231
231
|
]}
|
|
232
232
|
>
|
|
233
|
-
<
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
233
|
+
<View
|
|
234
|
+
style={[
|
|
235
|
+
styles.fileContainer,
|
|
236
|
+
index === fileUploads.length - 1
|
|
237
|
+
? {
|
|
238
|
+
marginBottom: 0,
|
|
239
|
+
}
|
|
240
|
+
: {},
|
|
241
|
+
{
|
|
242
|
+
backgroundColor: white,
|
|
243
|
+
borderColor: grey_whisper,
|
|
244
|
+
width: -16,
|
|
245
|
+
},
|
|
246
|
+
fileContainer,
|
|
247
|
+
]}
|
|
239
248
|
testID='audio-attachment-upload-preview'
|
|
240
|
-
|
|
249
|
+
>
|
|
250
|
+
<AudioAttachment
|
|
251
|
+
item={item}
|
|
252
|
+
onLoad={onLoad}
|
|
253
|
+
onPlayPause={onPlayPause}
|
|
254
|
+
onProgress={onProgress}
|
|
255
|
+
testID='audio-attachment-upload-preview'
|
|
256
|
+
/>
|
|
257
|
+
</View>
|
|
241
258
|
</View>
|
|
242
259
|
) : (
|
|
243
260
|
<View
|
|
@@ -296,18 +313,9 @@ const FileUploadPreviewWithContext = <
|
|
|
296
313
|
style={[styles.dismiss, { backgroundColor: grey_gainsboro }, dismiss]}
|
|
297
314
|
testID='remove-file-upload-preview'
|
|
298
315
|
>
|
|
299
|
-
<Close />
|
|
316
|
+
<Close pathFill={grey_dark} />
|
|
300
317
|
</TouchableOpacity>
|
|
301
318
|
</UploadProgressIndicator>
|
|
302
|
-
<TouchableOpacity
|
|
303
|
-
onPress={() => {
|
|
304
|
-
removeFile(item.id);
|
|
305
|
-
}}
|
|
306
|
-
style={[styles.dismiss, { backgroundColor: grey_gainsboro }, dismiss]}
|
|
307
|
-
testID='remove-file-upload-preview'
|
|
308
|
-
>
|
|
309
|
-
<Close pathFill={grey_dark} />
|
|
310
|
-
</TouchableOpacity>
|
|
311
319
|
</>
|
|
312
320
|
);
|
|
313
321
|
};
|
|
@@ -380,14 +388,14 @@ export const FileUploadPreview = <
|
|
|
380
388
|
>(
|
|
381
389
|
props: FileUploadPreviewProps<StreamChatGenerics>,
|
|
382
390
|
) => {
|
|
383
|
-
const {
|
|
391
|
+
const { fileUploads, removeFile, setFileUploads, uploadFile } =
|
|
384
392
|
useMessageInputContext<StreamChatGenerics>();
|
|
385
|
-
const { FileAttachmentIcon } = useMessagesContext<StreamChatGenerics>();
|
|
393
|
+
const { AudioAttachment, FileAttachmentIcon } = useMessagesContext<StreamChatGenerics>();
|
|
386
394
|
|
|
387
395
|
return (
|
|
388
396
|
<MemoizedFileUploadPreview
|
|
389
397
|
{...{
|
|
390
|
-
|
|
398
|
+
AudioAttachment,
|
|
391
399
|
FileAttachmentIcon,
|
|
392
400
|
fileUploads,
|
|
393
401
|
removeFile,
|
|
@@ -4,15 +4,16 @@ import { act } from 'react-test-renderer';
|
|
|
4
4
|
|
|
5
5
|
import { fireEvent, render } from '@testing-library/react-native';
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import {
|
|
8
|
+
FileUpload,
|
|
9
|
+
MessageInputContext,
|
|
10
|
+
MessageInputContextValue,
|
|
11
|
+
} from '../../../contexts/messageInputContext/MessageInputContext';
|
|
8
12
|
import { ThemeProvider } from '../../../contexts/themeContext/ThemeContext';
|
|
9
13
|
import { defaultTheme } from '../../../contexts/themeContext/utils/theme';
|
|
10
14
|
|
|
11
15
|
import { generateFileUploadPreview } from '../../../mock-builders/generator/attachment';
|
|
12
|
-
import {
|
|
13
|
-
AudioAttachmentUploadPreview,
|
|
14
|
-
AudioAttachmentUploadPreviewProps,
|
|
15
|
-
} from '../AudioAttachmentUploadPreview';
|
|
16
|
+
import { AudioAttachment, AudioAttachmentProps } from '../../Attachment/AudioAttachment';
|
|
16
17
|
|
|
17
18
|
jest.mock('../../../native.ts', () => ({
|
|
18
19
|
isAudioPackageAvailable: jest.fn(() => true),
|
|
@@ -29,13 +30,19 @@ jest.mock('react-native/Libraries/ReactNative/I18nManager', () => ({
|
|
|
29
30
|
isRTL: true,
|
|
30
31
|
}));
|
|
31
32
|
|
|
32
|
-
const getComponent = (
|
|
33
|
+
const getComponent = (
|
|
34
|
+
props: Partial<AudioAttachmentProps & Pick<MessageInputContextValue, 'fileUploads'>>,
|
|
35
|
+
) => (
|
|
33
36
|
<ThemeProvider theme={defaultTheme}>
|
|
34
|
-
<
|
|
37
|
+
<MessageInputContext.Provider
|
|
38
|
+
value={{ fileUploads: props.fileUploads } as unknown as MessageInputContextValue}
|
|
39
|
+
>
|
|
40
|
+
<AudioAttachment {...(props as unknown as AudioAttachmentProps)} />,
|
|
41
|
+
</MessageInputContext.Provider>
|
|
35
42
|
</ThemeProvider>
|
|
36
43
|
);
|
|
37
44
|
|
|
38
|
-
describe('
|
|
45
|
+
describe('AudioAttachmentExpo', () => {
|
|
39
46
|
it('handle play pause button when isPausedStatusAvailable unavailable and progress 1', () => {
|
|
40
47
|
const setPositionAsyncMock = jest.fn();
|
|
41
48
|
jest.spyOn(React, 'useRef').mockReturnValue({
|
|
@@ -4,15 +4,16 @@ import { act } from 'react-test-renderer';
|
|
|
4
4
|
|
|
5
5
|
import { fireEvent, render } from '@testing-library/react-native';
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import {
|
|
8
|
+
FileUpload,
|
|
9
|
+
MessageInputContext,
|
|
10
|
+
MessageInputContextValue,
|
|
11
|
+
} from '../../../contexts/messageInputContext/MessageInputContext';
|
|
8
12
|
import { ThemeProvider } from '../../../contexts/themeContext/ThemeContext';
|
|
9
13
|
import { defaultTheme } from '../../../contexts/themeContext/utils/theme';
|
|
10
14
|
|
|
11
15
|
import { generateFileUploadPreview } from '../../../mock-builders/generator/attachment';
|
|
12
|
-
import {
|
|
13
|
-
AudioAttachmentUploadPreview,
|
|
14
|
-
AudioAttachmentUploadPreviewProps,
|
|
15
|
-
} from '../AudioAttachmentUploadPreview';
|
|
16
|
+
import { AudioAttachment, AudioAttachmentProps } from '../../Attachment/AudioAttachment';
|
|
16
17
|
|
|
17
18
|
jest.mock('../../../native.ts', () => {
|
|
18
19
|
const View = require('react-native/Libraries/Components/View/View');
|
|
@@ -28,13 +29,19 @@ jest.mock('../../../native.ts', () => {
|
|
|
28
29
|
};
|
|
29
30
|
});
|
|
30
31
|
|
|
31
|
-
const getComponent = (
|
|
32
|
+
const getComponent = (
|
|
33
|
+
props: Partial<AudioAttachmentProps & Pick<MessageInputContextValue, 'fileUploads'>>,
|
|
34
|
+
) => (
|
|
32
35
|
<ThemeProvider theme={defaultTheme}>
|
|
33
|
-
<
|
|
36
|
+
<MessageInputContext.Provider
|
|
37
|
+
value={{ fileUploads: props.fileUploads } as unknown as MessageInputContextValue}
|
|
38
|
+
>
|
|
39
|
+
<AudioAttachment {...(props as unknown as AudioAttachmentProps)} />,
|
|
40
|
+
</MessageInputContext.Provider>
|
|
34
41
|
</ThemeProvider>
|
|
35
42
|
);
|
|
36
43
|
|
|
37
|
-
describe('
|
|
44
|
+
describe('AudioAttachment', () => {
|
|
38
45
|
it('handle play pause button when isPausedStatusAvailable unavailable and progress 1', () => {
|
|
39
46
|
const seekMock = jest.fn();
|
|
40
47
|
jest.spyOn(React, 'useRef').mockReturnValue({
|
|
@@ -351,13 +351,13 @@ describe('FileUploadPreview', () => {
|
|
|
351
351
|
</OverlayProvider>,
|
|
352
352
|
);
|
|
353
353
|
|
|
354
|
-
const
|
|
354
|
+
const AudioAttachmentComponent = getByTestId('audio-attachment-upload-preview');
|
|
355
355
|
|
|
356
356
|
await waitFor(() => {
|
|
357
|
-
fireEvent(
|
|
358
|
-
fireEvent(
|
|
359
|
-
fireEvent(
|
|
360
|
-
fireEvent(
|
|
357
|
+
fireEvent(AudioAttachmentComponent, 'onLoad');
|
|
358
|
+
fireEvent(AudioAttachmentComponent, 'onProgress');
|
|
359
|
+
fireEvent(AudioAttachmentComponent, 'onPlayPause');
|
|
360
|
+
fireEvent(AudioAttachmentComponent, 'onPlayPause', {
|
|
361
361
|
status: false,
|
|
362
362
|
});
|
|
363
363
|
});
|
|
@@ -124,7 +124,7 @@ type MessageListPropsWithContext<
|
|
|
124
124
|
| 'targetedMessage'
|
|
125
125
|
> &
|
|
126
126
|
Pick<ChatContextValue<StreamChatGenerics>, 'client'> &
|
|
127
|
-
Pick<ImageGalleryContextValue<StreamChatGenerics>, '
|
|
127
|
+
Pick<ImageGalleryContextValue<StreamChatGenerics>, 'setMessages'> &
|
|
128
128
|
Pick<
|
|
129
129
|
PaginatedMessageListContextValue<StreamChatGenerics>,
|
|
130
130
|
'hasNoMoreRecentMessagesToLoad' | 'loadMore' | 'loadMoreRecent'
|
|
@@ -270,7 +270,7 @@ const MessageListWithContext = <
|
|
|
270
270
|
scrollToFirstUnreadThreshold,
|
|
271
271
|
selectedPicker,
|
|
272
272
|
setFlatListRef,
|
|
273
|
-
|
|
273
|
+
setMessages,
|
|
274
274
|
setSelectedPicker,
|
|
275
275
|
setTargetedMessage,
|
|
276
276
|
StickyHeader,
|
|
@@ -530,7 +530,7 @@ const MessageListWithContext = <
|
|
|
530
530
|
index: number;
|
|
531
531
|
item: MessageType<StreamChatGenerics>;
|
|
532
532
|
}) => {
|
|
533
|
-
if (!channel || (!channel.initialized && !channel.
|
|
533
|
+
if (!channel || (!channel.initialized && !channel.offlineMode)) return null;
|
|
534
534
|
|
|
535
535
|
const lastRead = channel.lastRead();
|
|
536
536
|
|
|
@@ -898,7 +898,7 @@ const MessageListWithContext = <
|
|
|
898
898
|
isListActive &&
|
|
899
899
|
((threadList && thread) || (!threadList && !thread))
|
|
900
900
|
) {
|
|
901
|
-
|
|
901
|
+
setMessages(messagesWithImages as MessageType<StreamChatGenerics>[]);
|
|
902
902
|
}
|
|
903
903
|
}, [
|
|
904
904
|
imageString,
|
|
@@ -1044,7 +1044,7 @@ export const MessageList = <
|
|
|
1044
1044
|
targetedMessage,
|
|
1045
1045
|
} = useChannelContext<StreamChatGenerics>();
|
|
1046
1046
|
const { client } = useChatContext<StreamChatGenerics>();
|
|
1047
|
-
const {
|
|
1047
|
+
const { setMessages } = useImageGalleryContext<StreamChatGenerics>();
|
|
1048
1048
|
const {
|
|
1049
1049
|
DateHeader,
|
|
1050
1050
|
deletedMessagesVisibilityType,
|
|
@@ -1104,7 +1104,7 @@ export const MessageList = <
|
|
|
1104
1104
|
ScrollToBottomButton,
|
|
1105
1105
|
scrollToFirstUnreadThreshold,
|
|
1106
1106
|
selectedPicker,
|
|
1107
|
-
|
|
1107
|
+
setMessages,
|
|
1108
1108
|
setSelectedPicker,
|
|
1109
1109
|
setTargetedMessage,
|
|
1110
1110
|
StickyHeader,
|
|
@@ -321,6 +321,7 @@ exports[`Thread should match thread snapshot 1`] = `
|
|
|
321
321
|
"width": 32,
|
|
322
322
|
},
|
|
323
323
|
Object {
|
|
324
|
+
"backgroundColor": "#ececec",
|
|
324
325
|
"borderRadius": 16,
|
|
325
326
|
"height": 32,
|
|
326
327
|
"width": 32,
|
|
@@ -569,6 +570,7 @@ exports[`Thread should match thread snapshot 1`] = `
|
|
|
569
570
|
"width": 32,
|
|
570
571
|
},
|
|
571
572
|
Object {
|
|
573
|
+
"backgroundColor": "#ececec",
|
|
572
574
|
"borderRadius": 16,
|
|
573
575
|
"height": 32,
|
|
574
576
|
"width": 32,
|
|
@@ -817,6 +819,7 @@ exports[`Thread should match thread snapshot 1`] = `
|
|
|
817
819
|
"width": 32,
|
|
818
820
|
},
|
|
819
821
|
Object {
|
|
822
|
+
"backgroundColor": "#ececec",
|
|
820
823
|
"borderRadius": 16,
|
|
821
824
|
"height": 32,
|
|
822
825
|
"width": 32,
|
|
@@ -1108,6 +1111,7 @@ exports[`Thread should match thread snapshot 1`] = `
|
|
|
1108
1111
|
"width": 32,
|
|
1109
1112
|
},
|
|
1110
1113
|
Object {
|
|
1114
|
+
"backgroundColor": "#ececec",
|
|
1111
1115
|
"borderRadius": 16,
|
|
1112
1116
|
"height": 32,
|
|
1113
1117
|
"width": 32,
|
package/src/components/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './Attachment/Attachment';
|
|
2
2
|
export * from './Attachment/AttachmentActions';
|
|
3
|
+
export * from './Attachment/AudioAttachment';
|
|
3
4
|
export * from './Attachment/Card';
|
|
4
5
|
export * from './Attachment/FileAttachment';
|
|
5
6
|
export * from './Attachment/FileAttachmentGroup';
|
|
@@ -114,7 +115,6 @@ export * from './MessageInput/AttachButton';
|
|
|
114
115
|
export * from './MessageInput/CommandsButton';
|
|
115
116
|
export * from './MessageInput/CooldownTimer';
|
|
116
117
|
export * from './MessageInput/FileUploadPreview';
|
|
117
|
-
export * from './MessageInput/AudioAttachmentUploadPreview';
|
|
118
118
|
export * from './MessageInput/ImageUploadPreview';
|
|
119
119
|
export * from './MessageInput/InputButtons';
|
|
120
120
|
export * from './MessageInput/MessageInput';
|
|
@@ -8,7 +8,7 @@ can get access to context as following:
|
|
|
8
8
|
import { useChannelsContext } from 'stream-chat-react-native';
|
|
9
9
|
|
|
10
10
|
const SomeChildComponent = () => {
|
|
11
|
-
const {
|
|
11
|
+
const { selectedMessage, setSelectedMessage, setMessages } = useImageGalleryContext();
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
14
|
<View />
|
|
@@ -7,13 +7,18 @@ import { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';
|
|
|
7
7
|
import { getDisplayName } from '../utils/getDisplayName';
|
|
8
8
|
import { isTestEnvironment } from '../utils/isTestEnvironment';
|
|
9
9
|
|
|
10
|
+
type SelectedMessage = {
|
|
11
|
+
messageId?: string;
|
|
12
|
+
url?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
10
15
|
export type ImageGalleryContextValue<
|
|
11
16
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
12
17
|
> = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
messages: MessageType<StreamChatGenerics>[];
|
|
19
|
+
setMessages: React.Dispatch<React.SetStateAction<MessageType<StreamChatGenerics>[]>>;
|
|
20
|
+
setSelectedMessage: React.Dispatch<React.SetStateAction<SelectedMessage | undefined>>;
|
|
21
|
+
selectedMessage?: SelectedMessage;
|
|
17
22
|
};
|
|
18
23
|
|
|
19
24
|
export const ImageGalleryContext = React.createContext(
|
|
@@ -25,19 +30,19 @@ export const ImageGalleryProvider = <
|
|
|
25
30
|
>({
|
|
26
31
|
children,
|
|
27
32
|
}: PropsWithChildren<UnknownType>) => {
|
|
28
|
-
const [
|
|
29
|
-
const [
|
|
30
|
-
|
|
31
|
-
const imageGalleryContext = {
|
|
32
|
-
image,
|
|
33
|
-
images,
|
|
34
|
-
setImage,
|
|
35
|
-
setImages,
|
|
36
|
-
};
|
|
33
|
+
const [messages, setMessages] = useState<MessageType<StreamChatGenerics>[]>([]);
|
|
34
|
+
const [selectedMessage, setSelectedMessage] = useState<SelectedMessage>();
|
|
37
35
|
|
|
38
36
|
return (
|
|
39
37
|
<ImageGalleryContext.Provider
|
|
40
|
-
value={
|
|
38
|
+
value={
|
|
39
|
+
{
|
|
40
|
+
messages,
|
|
41
|
+
selectedMessage,
|
|
42
|
+
setMessages,
|
|
43
|
+
setSelectedMessage,
|
|
44
|
+
} as unknown as ImageGalleryContextValue
|
|
45
|
+
}
|
|
41
46
|
>
|
|
42
47
|
{children}
|
|
43
48
|
</ImageGalleryContext.Provider>
|
|
@@ -22,7 +22,6 @@ import { useCreateMessageInputContext } from './hooks/useCreateMessageInputConte
|
|
|
22
22
|
import { isEditingBoolean, useMessageDetailsForState } from './hooks/useMessageDetailsForState';
|
|
23
23
|
|
|
24
24
|
import type { AttachButtonProps } from '../../components/MessageInput/AttachButton';
|
|
25
|
-
import type { AudioAttachmentUploadPreviewProps } from '../../components/MessageInput/AudioAttachmentUploadPreview';
|
|
26
25
|
import type { CommandsButtonProps } from '../../components/MessageInput/CommandsButton';
|
|
27
26
|
import type { InputEditingStateHeaderProps } from '../../components/MessageInput/components/InputEditingStateHeader';
|
|
28
27
|
import type { InputGiphySearchProps } from '../../components/MessageInput/components/InputGiphySearch';
|
|
@@ -225,11 +224,6 @@ export type InputMessageInputContextValue<
|
|
|
225
224
|
*/
|
|
226
225
|
AttachButton: React.ComponentType<AttachButtonProps<StreamChatGenerics>>;
|
|
227
226
|
|
|
228
|
-
/** Custom UI component for AudioAttachmentUploadPreview. */
|
|
229
|
-
AudioAttachmentUploadPreview: React.ComponentType<
|
|
230
|
-
AudioAttachmentUploadPreviewProps<StreamChatGenerics>
|
|
231
|
-
>;
|
|
232
|
-
|
|
233
227
|
clearEditingState: () => void;
|
|
234
228
|
clearQuotedMessageState: () => void;
|
|
235
229
|
/**
|
|
@@ -12,7 +12,6 @@ export const useCreateMessageInputContext = <
|
|
|
12
12
|
asyncIds,
|
|
13
13
|
asyncUploads,
|
|
14
14
|
AttachButton,
|
|
15
|
-
AudioAttachmentUploadPreview,
|
|
16
15
|
autoCompleteSuggestionsLimit,
|
|
17
16
|
clearEditingState,
|
|
18
17
|
clearQuotedMessageState,
|
|
@@ -116,7 +115,6 @@ export const useCreateMessageInputContext = <
|
|
|
116
115
|
asyncIds,
|
|
117
116
|
asyncUploads,
|
|
118
117
|
AttachButton,
|
|
119
|
-
AudioAttachmentUploadPreview,
|
|
120
118
|
autoCompleteSuggestionsLimit,
|
|
121
119
|
clearEditingState,
|
|
122
120
|
clearQuotedMessageState,
|
|
@@ -11,6 +11,7 @@ import type { Attachment, ChannelState, MessageResponse } from 'stream-chat';
|
|
|
11
11
|
|
|
12
12
|
import type { AttachmentProps } from '../../components/Attachment/Attachment';
|
|
13
13
|
import type { AttachmentActionsProps } from '../../components/Attachment/AttachmentActions';
|
|
14
|
+
import type { AudioAttachmentProps } from '../../components/Attachment/AudioAttachment';
|
|
14
15
|
import type { CardProps } from '../../components/Attachment/Card';
|
|
15
16
|
import type { FileAttachmentProps } from '../../components/Attachment/FileAttachment';
|
|
16
17
|
import type { FileAttachmentGroupProps } from '../../components/Attachment/FileAttachmentGroup';
|
|
@@ -72,6 +73,8 @@ export type MessagesContextValue<
|
|
|
72
73
|
* Defaults to: [AttachmentActions](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/Attachment/AttachmentActions.tsx)
|
|
73
74
|
*/
|
|
74
75
|
AttachmentActions: React.ComponentType<AttachmentActionsProps<StreamChatGenerics>>;
|
|
76
|
+
/** Custom UI component for AudioAttachment. */
|
|
77
|
+
AudioAttachment: React.ComponentType<AudioAttachmentProps>;
|
|
75
78
|
/**
|
|
76
79
|
* UI component to display generic media type e.g. giphy, url preview etc
|
|
77
80
|
* Defaults to: [Card](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/Attachment/Card.tsx)
|