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
|
@@ -4,12 +4,7 @@ import { I18nManager, StyleSheet, Text, TouchableOpacity, View } from 'react-nat
|
|
|
4
4
|
import dayjs from 'dayjs';
|
|
5
5
|
import duration from 'dayjs/plugin/duration';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
FileUpload,
|
|
9
|
-
MessageInputContextValue,
|
|
10
|
-
useMessageInputContext,
|
|
11
|
-
useTheme,
|
|
12
|
-
} from '../../contexts';
|
|
7
|
+
import { FileUpload, useTheme } from '../../contexts';
|
|
13
8
|
import { Pause, Play } from '../../icons';
|
|
14
9
|
import {
|
|
15
10
|
PlaybackStatus,
|
|
@@ -18,7 +13,6 @@ import {
|
|
|
18
13
|
VideoPayloadData,
|
|
19
14
|
VideoProgressData,
|
|
20
15
|
} from '../../native';
|
|
21
|
-
import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
22
16
|
import { ProgressControl } from '../ProgressControl/ProgressControl';
|
|
23
17
|
|
|
24
18
|
dayjs.extend(duration);
|
|
@@ -34,7 +28,7 @@ const styles = StyleSheet.create({
|
|
|
34
28
|
paddingLeft: 8,
|
|
35
29
|
paddingRight: 8,
|
|
36
30
|
},
|
|
37
|
-
fileContentContainer: { flexDirection: 'row' },
|
|
31
|
+
fileContentContainer: { flexDirection: 'row', paddingRight: 40 },
|
|
38
32
|
filenameText: {
|
|
39
33
|
fontSize: 14,
|
|
40
34
|
fontWeight: 'bold',
|
|
@@ -76,27 +70,17 @@ const styles = StyleSheet.create({
|
|
|
76
70
|
},
|
|
77
71
|
});
|
|
78
72
|
|
|
79
|
-
export type
|
|
80
|
-
|
|
81
|
-
> = Pick<
|
|
82
|
-
MessageInputContextValue<StreamChatGenerics>,
|
|
83
|
-
'fileUploads' | 'removeFile' | 'uploadFile'
|
|
84
|
-
> & {
|
|
85
|
-
index: number;
|
|
86
|
-
item: FileUpload;
|
|
73
|
+
export type AudioAttachmentPropsWithContext = {
|
|
74
|
+
item: Omit<FileUpload, 'state'>;
|
|
87
75
|
onLoad: (index: string, duration: number) => void;
|
|
88
|
-
onPlayPause: (index: string,
|
|
76
|
+
onPlayPause: (index: string, pausedStatus?: boolean) => void;
|
|
89
77
|
onProgress: (index: string, currentTime?: number, hasEnd?: boolean) => void;
|
|
90
|
-
testID
|
|
78
|
+
testID?: string;
|
|
91
79
|
};
|
|
92
80
|
|
|
93
|
-
const
|
|
94
|
-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
95
|
-
>(
|
|
96
|
-
props: AudioAttachmentUploadPreviewPropsWithContext<StreamChatGenerics>,
|
|
97
|
-
) => {
|
|
81
|
+
const AudioAttachmentWithContext = (props: AudioAttachmentPropsWithContext) => {
|
|
98
82
|
const soundRef = React.useRef<SoundReturnType | null>(null);
|
|
99
|
-
const {
|
|
83
|
+
const { item, onLoad, onPlayPause, onProgress } = props;
|
|
100
84
|
|
|
101
85
|
const handleLoad = (payload: VideoPayloadData) => {
|
|
102
86
|
onLoad(item.id, payload.duration);
|
|
@@ -212,11 +196,10 @@ const AudioAttachmentUploadPreviewWithContext = <
|
|
|
212
196
|
|
|
213
197
|
const {
|
|
214
198
|
theme: {
|
|
215
|
-
colors: { accent_blue, black, grey_dark,
|
|
199
|
+
colors: { accent_blue, black, grey_dark, static_black, static_white },
|
|
216
200
|
messageInput: {
|
|
217
201
|
fileUploadPreview: {
|
|
218
|
-
|
|
219
|
-
fileContainer,
|
|
202
|
+
audioAttachment: { progressControlView, progressDurationText, roundedView },
|
|
220
203
|
fileContentContainer,
|
|
221
204
|
filenameText,
|
|
222
205
|
fileTextContainer,
|
|
@@ -236,91 +219,74 @@ const AudioAttachmentUploadPreviewWithContext = <
|
|
|
236
219
|
const lastIndexOfDot = item.file.name.lastIndexOf('.');
|
|
237
220
|
|
|
238
221
|
return (
|
|
239
|
-
<View
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
:
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
<View style={[styles.
|
|
256
|
-
<
|
|
257
|
-
accessibilityLabel='
|
|
258
|
-
|
|
222
|
+
<View style={[styles.fileContentContainer, fileContentContainer]}>
|
|
223
|
+
<TouchableOpacity
|
|
224
|
+
accessibilityLabel='Play Pause Button'
|
|
225
|
+
onPress={() => handlePlayPause()}
|
|
226
|
+
style={[
|
|
227
|
+
styles.roundedView,
|
|
228
|
+
roundedView,
|
|
229
|
+
{ backgroundColor: static_white, shadowColor: black },
|
|
230
|
+
]}
|
|
231
|
+
>
|
|
232
|
+
{item.paused ? (
|
|
233
|
+
<Play height={24} pathFill={static_black} width={24} />
|
|
234
|
+
) : (
|
|
235
|
+
<Pause height={24} pathFill={static_black} width={24} />
|
|
236
|
+
)}
|
|
237
|
+
</TouchableOpacity>
|
|
238
|
+
<View style={[styles.fileTextContainer, fileTextContainer]}>
|
|
239
|
+
<Text
|
|
240
|
+
accessibilityLabel='File Name'
|
|
241
|
+
numberOfLines={1}
|
|
259
242
|
style={[
|
|
260
|
-
styles.
|
|
261
|
-
|
|
262
|
-
|
|
243
|
+
styles.filenameText,
|
|
244
|
+
{
|
|
245
|
+
color: black,
|
|
246
|
+
width:
|
|
247
|
+
16 - // 16 = horizontal padding
|
|
248
|
+
40 - // 40 = file icon size
|
|
249
|
+
24 - // 24 = close icon size
|
|
250
|
+
24, // 24 = internal padding
|
|
251
|
+
},
|
|
252
|
+
I18nManager.isRTL ? { writingDirection: 'rtl' } : { writingDirection: 'ltr' },
|
|
253
|
+
filenameText,
|
|
263
254
|
]}
|
|
264
255
|
>
|
|
265
|
-
{item.
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
256
|
+
{item.file.name.slice(0, 12) + '...' + item.file.name.slice(lastIndexOfDot)}
|
|
257
|
+
</Text>
|
|
258
|
+
<View
|
|
259
|
+
style={{
|
|
260
|
+
alignItems: 'center',
|
|
261
|
+
display: 'flex',
|
|
262
|
+
flexDirection: 'row',
|
|
263
|
+
}}
|
|
264
|
+
>
|
|
265
|
+
{/* <ExpoSoundPlayer filePaused={!!item.paused} soundRef={soundRef} /> */}
|
|
266
|
+
{Sound.Player && (
|
|
267
|
+
<Sound.Player
|
|
268
|
+
onEnd={handleEnd}
|
|
269
|
+
onLoad={handleLoad}
|
|
270
|
+
onProgress={handleProgress}
|
|
271
|
+
paused={item.paused as boolean}
|
|
272
|
+
soundRef={soundRef}
|
|
273
|
+
testID='sound-player'
|
|
274
|
+
uri={item.file.uri}
|
|
275
|
+
/>
|
|
269
276
|
)}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
<Text
|
|
273
|
-
accessibilityLabel='File Name'
|
|
274
|
-
numberOfLines={1}
|
|
275
|
-
style={[
|
|
276
|
-
styles.filenameText,
|
|
277
|
-
{
|
|
278
|
-
color: black,
|
|
279
|
-
width:
|
|
280
|
-
16 - // 16 = horizontal padding
|
|
281
|
-
40 - // 40 = file icon size
|
|
282
|
-
24 - // 24 = close icon size
|
|
283
|
-
24, // 24 = internal padding
|
|
284
|
-
},
|
|
285
|
-
I18nManager.isRTL ? { writingDirection: 'rtl' } : { writingDirection: 'ltr' },
|
|
286
|
-
filenameText,
|
|
287
|
-
]}
|
|
288
|
-
>
|
|
289
|
-
{item.file.name.slice(0, 12) + '...' + item.file.name.slice(lastIndexOfDot)}
|
|
277
|
+
<Text style={[styles.progressDurationText, { color: grey_dark }, progressDurationText]}>
|
|
278
|
+
{progressDuration}
|
|
290
279
|
</Text>
|
|
291
|
-
<View
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
onEnd={handleEnd}
|
|
302
|
-
onLoad={handleLoad}
|
|
303
|
-
onProgress={handleProgress}
|
|
304
|
-
paused={item.paused as boolean}
|
|
305
|
-
soundRef={soundRef}
|
|
306
|
-
testID='sound-player'
|
|
307
|
-
uri={item.file.uri}
|
|
308
|
-
/>
|
|
309
|
-
)}
|
|
310
|
-
<Text style={[styles.progressDurationText, { color: grey_dark }, progressDurationText]}>
|
|
311
|
-
{progressDuration}
|
|
312
|
-
</Text>
|
|
313
|
-
<View style={[styles.progressControlView, progressControlView]}>
|
|
314
|
-
<ProgressControl
|
|
315
|
-
duration={item.duration as number}
|
|
316
|
-
filledColor={accent_blue}
|
|
317
|
-
onPlayPause={handlePlayPause}
|
|
318
|
-
onProgressDrag={handleProgressDrag}
|
|
319
|
-
progress={item.progress as number}
|
|
320
|
-
testID='progress-control'
|
|
321
|
-
width={110}
|
|
322
|
-
/>
|
|
323
|
-
</View>
|
|
280
|
+
<View style={[styles.progressControlView, progressControlView]}>
|
|
281
|
+
<ProgressControl
|
|
282
|
+
duration={item.duration as number}
|
|
283
|
+
filledColor={accent_blue}
|
|
284
|
+
onPlayPause={handlePlayPause}
|
|
285
|
+
onProgressDrag={handleProgressDrag}
|
|
286
|
+
progress={item.progress as number}
|
|
287
|
+
testID='progress-control'
|
|
288
|
+
width={120}
|
|
289
|
+
/>
|
|
324
290
|
</View>
|
|
325
291
|
</View>
|
|
326
292
|
</View>
|
|
@@ -328,35 +294,20 @@ const AudioAttachmentUploadPreviewWithContext = <
|
|
|
328
294
|
);
|
|
329
295
|
};
|
|
330
296
|
|
|
331
|
-
export type
|
|
332
|
-
|
|
333
|
-
> = Partial<AudioAttachmentUploadPreviewPropsWithContext<StreamChatGenerics>> & {
|
|
334
|
-
index: number;
|
|
335
|
-
item: FileUpload;
|
|
297
|
+
export type AudioAttachmentProps = Partial<AudioAttachmentPropsWithContext> & {
|
|
298
|
+
item: Omit<FileUpload, 'state'>;
|
|
336
299
|
onLoad: (index: string, duration: number) => void;
|
|
337
|
-
onPlayPause: (index: string,
|
|
300
|
+
onPlayPause: (index: string, pausedStatus?: boolean) => void;
|
|
338
301
|
onProgress: (index: string, currentTime?: number, hasEnd?: boolean) => void;
|
|
339
302
|
testID: string;
|
|
340
303
|
};
|
|
341
304
|
|
|
342
305
|
/**
|
|
343
|
-
*
|
|
344
|
-
* UI Component to preview the audio files
|
|
306
|
+
* AudioAttachment
|
|
307
|
+
* UI Component to preview the audio files
|
|
345
308
|
*/
|
|
346
|
-
export const
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
props: AudioAttachmentUploadPreviewProps<StreamChatGenerics>,
|
|
350
|
-
) => {
|
|
351
|
-
const { fileUploads, removeFile, uploadFile } = useMessageInputContext<StreamChatGenerics>();
|
|
352
|
-
|
|
353
|
-
return (
|
|
354
|
-
<AudioAttachmentUploadPreviewWithContext
|
|
355
|
-
{...{ fileUploads, removeFile, uploadFile }}
|
|
356
|
-
{...props}
|
|
357
|
-
/>
|
|
358
|
-
);
|
|
359
|
-
};
|
|
309
|
+
export const AudioAttachment = (props: AudioAttachmentProps) => (
|
|
310
|
+
<AudioAttachmentWithContext {...props} />
|
|
311
|
+
);
|
|
360
312
|
|
|
361
|
-
|
|
362
|
-
'AudioAttachmentUploadPreview{messageInput{autoAttachmentUploadPreview}}';
|
|
313
|
+
AudioAttachment.displayName = 'AudioAttachment{messageInput{autoAttachment}}';
|
|
@@ -103,6 +103,7 @@ const FileAttachmentWithContext = <
|
|
|
103
103
|
onLongPress={(event) => {
|
|
104
104
|
if (onLongPress) {
|
|
105
105
|
onLongPress({
|
|
106
|
+
additionalInfo: { attachment },
|
|
106
107
|
emitter: 'fileAttachment',
|
|
107
108
|
event,
|
|
108
109
|
});
|
|
@@ -111,6 +112,7 @@ const FileAttachmentWithContext = <
|
|
|
111
112
|
onPress={(event) => {
|
|
112
113
|
if (onPress) {
|
|
113
114
|
onPress({
|
|
115
|
+
additionalInfo: { attachment },
|
|
114
116
|
defaultHandler: defaultOnPress,
|
|
115
117
|
emitter: 'fileAttachment',
|
|
116
118
|
event,
|
|
@@ -120,6 +122,7 @@ const FileAttachmentWithContext = <
|
|
|
120
122
|
onPressIn={(event) => {
|
|
121
123
|
if (onPressIn) {
|
|
122
124
|
onPressIn({
|
|
125
|
+
additionalInfo: { attachment },
|
|
123
126
|
defaultHandler: defaultOnPress,
|
|
124
127
|
emitter: 'fileAttachment',
|
|
125
128
|
event,
|
|
@@ -1,30 +1,45 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
|
|
3
3
|
|
|
4
|
+
import type { Attachment } from 'stream-chat';
|
|
5
|
+
|
|
4
6
|
import { Attachment as AttachmentDefault } from './Attachment';
|
|
5
7
|
|
|
6
8
|
import {
|
|
7
9
|
MessageContextValue,
|
|
8
10
|
useMessageContext,
|
|
9
11
|
} from '../../contexts/messageContext/MessageContext';
|
|
12
|
+
|
|
10
13
|
import {
|
|
11
14
|
MessagesContextValue,
|
|
12
15
|
useMessagesContext,
|
|
13
16
|
} from '../../contexts/messagesContext/MessagesContext';
|
|
14
17
|
import { useTheme } from '../../contexts/themeContext/ThemeContext';
|
|
18
|
+
import { isAudioPackageAvailable } from '../../native';
|
|
15
19
|
|
|
16
20
|
import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
17
21
|
|
|
22
|
+
const FILE_PREVIEW_HEIGHT = 60;
|
|
23
|
+
|
|
18
24
|
const styles = StyleSheet.create({
|
|
19
25
|
container: {
|
|
20
26
|
padding: 4,
|
|
21
27
|
},
|
|
28
|
+
fileContainer: {
|
|
29
|
+
borderRadius: 12,
|
|
30
|
+
borderWidth: 1,
|
|
31
|
+
flexDirection: 'row',
|
|
32
|
+
height: FILE_PREVIEW_HEIGHT,
|
|
33
|
+
justifyContent: 'space-between',
|
|
34
|
+
paddingLeft: 8,
|
|
35
|
+
paddingRight: 8,
|
|
36
|
+
},
|
|
22
37
|
});
|
|
23
38
|
|
|
24
39
|
export type FileAttachmentGroupPropsWithContext<
|
|
25
40
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
26
41
|
> = Pick<MessageContextValue<StreamChatGenerics>, 'files'> &
|
|
27
|
-
Pick<MessagesContextValue<StreamChatGenerics>, 'Attachment'> & {
|
|
42
|
+
Pick<MessagesContextValue<StreamChatGenerics>, 'Attachment' | 'AudioAttachment'> & {
|
|
28
43
|
/**
|
|
29
44
|
* The unique id for the message with file attachments
|
|
30
45
|
*/
|
|
@@ -35,15 +50,77 @@ export type FileAttachmentGroupPropsWithContext<
|
|
|
35
50
|
}>;
|
|
36
51
|
};
|
|
37
52
|
|
|
53
|
+
type FilesToDisplayType<
|
|
54
|
+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
55
|
+
> = Attachment<StreamChatGenerics> & {
|
|
56
|
+
duration: number;
|
|
57
|
+
paused: boolean;
|
|
58
|
+
progress: number;
|
|
59
|
+
};
|
|
60
|
+
|
|
38
61
|
const FileAttachmentGroupWithContext = <
|
|
39
62
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
40
63
|
>(
|
|
41
64
|
props: FileAttachmentGroupPropsWithContext<StreamChatGenerics>,
|
|
42
65
|
) => {
|
|
43
|
-
const { Attachment, files, messageId, styles: stylesProp = {} } = props;
|
|
66
|
+
const { Attachment, AudioAttachment, files, messageId, styles: stylesProp = {} } = props;
|
|
67
|
+
const [filesToDisplay, setFilesToDisplay] = useState<FilesToDisplayType[]>([]);
|
|
68
|
+
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
setFilesToDisplay(files.map((file) => ({ ...file, duration: 0, paused: true, progress: 0 })));
|
|
71
|
+
}, [files]);
|
|
72
|
+
|
|
73
|
+
// Handler triggered when an audio is loaded in the message input. The initial state is defined for the audio here and the duration is set.
|
|
74
|
+
const onLoad = (index: string, duration: number) => {
|
|
75
|
+
setFilesToDisplay((prevFilesToDisplay) =>
|
|
76
|
+
prevFilesToDisplay.map((fileToDisplay, id) => ({
|
|
77
|
+
...fileToDisplay,
|
|
78
|
+
duration: id.toString() === index ? duration : fileToDisplay.duration,
|
|
79
|
+
})),
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// The handler which is triggered when the audio progresses/ the thumb is dragged in the progress control. The progressed duration is set here.
|
|
84
|
+
const onProgress = (index: string, currentTime?: number, hasEnd?: boolean) => {
|
|
85
|
+
setFilesToDisplay((prevFileUploads) =>
|
|
86
|
+
prevFileUploads.map((fileUpload, id) => ({
|
|
87
|
+
...fileUpload,
|
|
88
|
+
progress:
|
|
89
|
+
id.toString() === index
|
|
90
|
+
? hasEnd
|
|
91
|
+
? 1
|
|
92
|
+
: currentTime
|
|
93
|
+
? currentTime / (fileUpload.duration as number)
|
|
94
|
+
: 0
|
|
95
|
+
: fileUpload.progress,
|
|
96
|
+
})),
|
|
97
|
+
);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// The handler which controls or sets the paused/played state of the audio.
|
|
101
|
+
const onPlayPause = (index: string, pausedStatus?: boolean) => {
|
|
102
|
+
if (pausedStatus === false) {
|
|
103
|
+
// If the status is false we set the audio with the index as playing and the others as paused.
|
|
104
|
+
setFilesToDisplay((prevFileUploads) =>
|
|
105
|
+
prevFileUploads.map((fileUpload, id) => ({
|
|
106
|
+
...fileUpload,
|
|
107
|
+
paused: id.toString() === index ? false : true,
|
|
108
|
+
})),
|
|
109
|
+
);
|
|
110
|
+
} else {
|
|
111
|
+
// If the status is true we simply set all the audio's paused state as true.
|
|
112
|
+
setFilesToDisplay((prevFileUploads) =>
|
|
113
|
+
prevFileUploads.map((fileUpload) => ({
|
|
114
|
+
...fileUpload,
|
|
115
|
+
paused: true,
|
|
116
|
+
})),
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
44
120
|
|
|
45
121
|
const {
|
|
46
122
|
theme: {
|
|
123
|
+
colors: { grey_whisper, white },
|
|
47
124
|
messageSimple: {
|
|
48
125
|
fileAttachmentGroup: { container },
|
|
49
126
|
},
|
|
@@ -52,7 +129,7 @@ const FileAttachmentGroupWithContext = <
|
|
|
52
129
|
|
|
53
130
|
return (
|
|
54
131
|
<View style={[styles.container, container, stylesProp.container]}>
|
|
55
|
-
{
|
|
132
|
+
{filesToDisplay.map((file, index) => (
|
|
56
133
|
<View
|
|
57
134
|
key={`${messageId}-${index}`}
|
|
58
135
|
style={[
|
|
@@ -60,7 +137,40 @@ const FileAttachmentGroupWithContext = <
|
|
|
60
137
|
stylesProp.attachmentContainer,
|
|
61
138
|
]}
|
|
62
139
|
>
|
|
63
|
-
|
|
140
|
+
{file.type === 'audio' && isAudioPackageAvailable() ? (
|
|
141
|
+
<View
|
|
142
|
+
accessibilityLabel='audio-attachment-preview'
|
|
143
|
+
style={[
|
|
144
|
+
styles.fileContainer,
|
|
145
|
+
index === filesToDisplay.length - 1
|
|
146
|
+
? {
|
|
147
|
+
marginBottom: 0,
|
|
148
|
+
}
|
|
149
|
+
: {},
|
|
150
|
+
{
|
|
151
|
+
backgroundColor: white,
|
|
152
|
+
borderColor: grey_whisper,
|
|
153
|
+
width: -16,
|
|
154
|
+
},
|
|
155
|
+
]}
|
|
156
|
+
>
|
|
157
|
+
<AudioAttachment
|
|
158
|
+
item={{
|
|
159
|
+
duration: file.duration,
|
|
160
|
+
file: { name: file.title as string, uri: file.asset_url },
|
|
161
|
+
id: index.toString(),
|
|
162
|
+
paused: file.paused,
|
|
163
|
+
progress: file.progress,
|
|
164
|
+
}}
|
|
165
|
+
onLoad={onLoad}
|
|
166
|
+
onPlayPause={onPlayPause}
|
|
167
|
+
onProgress={onProgress}
|
|
168
|
+
testID='audio-attachment-preview'
|
|
169
|
+
/>
|
|
170
|
+
</View>
|
|
171
|
+
) : (
|
|
172
|
+
<Attachment attachment={file} />
|
|
173
|
+
)}
|
|
64
174
|
</View>
|
|
65
175
|
))}
|
|
66
176
|
</View>
|
|
@@ -74,9 +184,7 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
74
184
|
const { files: prevFiles } = prevProps;
|
|
75
185
|
const { files: nextFiles } = nextProps;
|
|
76
186
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return filesEqual;
|
|
187
|
+
return prevFiles.length === nextFiles.length;
|
|
80
188
|
};
|
|
81
189
|
|
|
82
190
|
const MemoizedFileAttachmentGroup = React.memo(
|
|
@@ -98,7 +206,8 @@ export const FileAttachmentGroup = <
|
|
|
98
206
|
|
|
99
207
|
const { files: contextFiles } = useMessageContext<StreamChatGenerics>();
|
|
100
208
|
|
|
101
|
-
const { Attachment = AttachmentDefault } =
|
|
209
|
+
const { Attachment = AttachmentDefault, AudioAttachment } =
|
|
210
|
+
useMessagesContext<StreamChatGenerics>();
|
|
102
211
|
|
|
103
212
|
const files = propFiles || contextFiles;
|
|
104
213
|
|
|
@@ -108,6 +217,7 @@ export const FileAttachmentGroup = <
|
|
|
108
217
|
<MemoizedFileAttachmentGroup
|
|
109
218
|
{...{
|
|
110
219
|
Attachment,
|
|
220
|
+
AudioAttachment,
|
|
111
221
|
files,
|
|
112
222
|
messageId,
|
|
113
223
|
}}
|
|
@@ -62,6 +62,12 @@ const styles = StyleSheet.create({
|
|
|
62
62
|
left: 4,
|
|
63
63
|
position: 'absolute',
|
|
64
64
|
},
|
|
65
|
+
imageLoadingIndicatorContainer: {
|
|
66
|
+
height: '100%',
|
|
67
|
+
justifyContent: 'center',
|
|
68
|
+
position: 'absolute',
|
|
69
|
+
width: '100%',
|
|
70
|
+
},
|
|
65
71
|
imageLoadingIndicatorStyle: {
|
|
66
72
|
alignItems: 'center',
|
|
67
73
|
justifyContent: 'center',
|
|
@@ -77,7 +83,7 @@ const styles = StyleSheet.create({
|
|
|
77
83
|
|
|
78
84
|
export type GalleryPropsWithContext<
|
|
79
85
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
80
|
-
> = Pick<ImageGalleryContextValue<StreamChatGenerics>, '
|
|
86
|
+
> = Pick<ImageGalleryContextValue<StreamChatGenerics>, 'setSelectedMessage' | 'setMessages'> &
|
|
81
87
|
Pick<
|
|
82
88
|
MessageContextValue<StreamChatGenerics>,
|
|
83
89
|
| 'alignment'
|
|
@@ -135,9 +141,9 @@ const GalleryWithContext = <
|
|
|
135
141
|
onPress,
|
|
136
142
|
onPressIn,
|
|
137
143
|
preventPress,
|
|
138
|
-
|
|
139
|
-
setImages,
|
|
144
|
+
setMessages,
|
|
140
145
|
setOverlay,
|
|
146
|
+
setSelectedMessage,
|
|
141
147
|
threadList,
|
|
142
148
|
videos,
|
|
143
149
|
VideoThumbnail,
|
|
@@ -250,9 +256,9 @@ const GalleryWithContext = <
|
|
|
250
256
|
onPressIn={onPressIn}
|
|
251
257
|
preventPress={preventPress}
|
|
252
258
|
rowIndex={rowIndex}
|
|
253
|
-
|
|
254
|
-
setImages={setImages}
|
|
259
|
+
setMessages={setMessages}
|
|
255
260
|
setOverlay={setOverlay}
|
|
261
|
+
setSelectedMessage={setSelectedMessage}
|
|
256
262
|
thumbnail={thumbnail}
|
|
257
263
|
VideoThumbnail={VideoThumbnail}
|
|
258
264
|
/>
|
|
@@ -290,7 +296,7 @@ type GalleryThumbnailProps<
|
|
|
290
296
|
| 'ImageLoadingIndicator'
|
|
291
297
|
| 'ImageLoadingFailedIndicator'
|
|
292
298
|
> &
|
|
293
|
-
Pick<ImageGalleryContextValue<StreamChatGenerics>, '
|
|
299
|
+
Pick<ImageGalleryContextValue<StreamChatGenerics>, 'setSelectedMessage' | 'setMessages'> &
|
|
294
300
|
Pick<
|
|
295
301
|
MessageContextValue<StreamChatGenerics>,
|
|
296
302
|
'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'
|
|
@@ -316,9 +322,9 @@ const GalleryThumbnail = <
|
|
|
316
322
|
onPressIn,
|
|
317
323
|
preventPress,
|
|
318
324
|
rowIndex,
|
|
319
|
-
|
|
320
|
-
setImages,
|
|
325
|
+
setMessages,
|
|
321
326
|
setOverlay,
|
|
327
|
+
setSelectedMessage,
|
|
322
328
|
thumbnail,
|
|
323
329
|
VideoThumbnail,
|
|
324
330
|
}: GalleryThumbnailProps<StreamChatGenerics>) => {
|
|
@@ -336,11 +342,11 @@ const GalleryThumbnail = <
|
|
|
336
342
|
// Added if-else to keep the logic readable, instead of DRY.
|
|
337
343
|
// if - legacyImageViewerSwipeBehaviour is disabled
|
|
338
344
|
// else - legacyImageViewerSwipeBehaviour is enabled
|
|
339
|
-
|
|
340
|
-
|
|
345
|
+
setMessages([message]);
|
|
346
|
+
setSelectedMessage({ messageId: message.id, url: thumbnail.url });
|
|
341
347
|
setOverlay('gallery');
|
|
342
348
|
} else if (legacyImageViewerSwipeBehaviour) {
|
|
343
|
-
|
|
349
|
+
setSelectedMessage({ messageId: message?.id, url: thumbnail.url });
|
|
344
350
|
setOverlay('gallery');
|
|
345
351
|
}
|
|
346
352
|
};
|
|
@@ -490,7 +496,7 @@ const GalleryImageThumbnail = <
|
|
|
490
496
|
uri={thumbnail.url}
|
|
491
497
|
/>
|
|
492
498
|
{isLoadingImage && (
|
|
493
|
-
<View style={
|
|
499
|
+
<View style={[styles.imageLoadingIndicatorContainer]}>
|
|
494
500
|
<ImageLoadingIndicator style={styles.imageLoadingIndicatorStyle} />
|
|
495
501
|
</View>
|
|
496
502
|
)}
|
|
@@ -519,7 +525,9 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
519
525
|
videos: nextVideos,
|
|
520
526
|
} = nextProps;
|
|
521
527
|
|
|
522
|
-
const messageEqual =
|
|
528
|
+
const messageEqual =
|
|
529
|
+
prevMessage?.id === nextMessage?.id &&
|
|
530
|
+
`${prevMessage?.updated_at}` === `${nextMessage?.updated_at}`;
|
|
523
531
|
if (!messageEqual) return false;
|
|
524
532
|
|
|
525
533
|
const groupStylesEqual =
|
|
@@ -572,23 +580,25 @@ export const Gallery = <
|
|
|
572
580
|
ImageLoadingFailedIndicator: PropImageLoadingFailedIndicator,
|
|
573
581
|
ImageLoadingIndicator: PropImageLoadingIndicator,
|
|
574
582
|
images: propImages,
|
|
583
|
+
message: propMessage,
|
|
575
584
|
onLongPress: propOnLongPress,
|
|
576
585
|
onPress: propOnPress,
|
|
577
586
|
onPressIn: propOnPressIn,
|
|
578
587
|
preventPress: propPreventPress,
|
|
579
|
-
setImage: propSetImage,
|
|
580
588
|
setOverlay: propSetOverlay,
|
|
589
|
+
setSelectedMessage: propSetSelectedMessage,
|
|
581
590
|
threadList: propThreadList,
|
|
582
591
|
videos: propVideos,
|
|
583
592
|
VideoThumbnail: PropVideoThumbnail,
|
|
584
593
|
} = props;
|
|
585
594
|
|
|
586
|
-
const {
|
|
595
|
+
const { setMessages, setSelectedMessage: contextSetSelectedMessage } =
|
|
596
|
+
useImageGalleryContext<StreamChatGenerics>();
|
|
587
597
|
const {
|
|
588
598
|
alignment: contextAlignment,
|
|
589
599
|
groupStyles: contextGroupStyles,
|
|
590
600
|
images: contextImages,
|
|
591
|
-
message,
|
|
601
|
+
message: contextMessage,
|
|
592
602
|
onLongPress: contextOnLongPress,
|
|
593
603
|
onPress: contextOnPress,
|
|
594
604
|
onPressIn: contextOnPressIn,
|
|
@@ -607,6 +617,7 @@ export const Gallery = <
|
|
|
607
617
|
|
|
608
618
|
const images = propImages || contextImages;
|
|
609
619
|
const videos = propVideos || contextVideos;
|
|
620
|
+
const message = propMessage || contextMessage;
|
|
610
621
|
|
|
611
622
|
if (!images.length && !videos.length) return null;
|
|
612
623
|
|
|
@@ -618,7 +629,7 @@ export const Gallery = <
|
|
|
618
629
|
const onPress = propOnPress || contextOnPress;
|
|
619
630
|
const preventPress =
|
|
620
631
|
typeof propPreventPress === 'boolean' ? propPreventPress : contextPreventPress;
|
|
621
|
-
const
|
|
632
|
+
const setSelectedMessage = propSetSelectedMessage || contextSetSelectedMessage;
|
|
622
633
|
const setOverlay = propSetOverlay || contextSetOverlay;
|
|
623
634
|
const threadList = propThreadList || contextThreadList;
|
|
624
635
|
const VideoThumbnail = PropVideoThumbnail || ContextVideoThumnbnail;
|
|
@@ -643,9 +654,9 @@ export const Gallery = <
|
|
|
643
654
|
onPress,
|
|
644
655
|
onPressIn,
|
|
645
656
|
preventPress,
|
|
646
|
-
|
|
647
|
-
setImages,
|
|
657
|
+
setMessages,
|
|
648
658
|
setOverlay,
|
|
659
|
+
setSelectedMessage,
|
|
649
660
|
threadList,
|
|
650
661
|
videos,
|
|
651
662
|
VideoThumbnail,
|