stream-chat-react-native-core 9.5.1 → 9.5.2-beta.2
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/README.md +1 -1
- package/lib/commonjs/components/Attachment/FileAttachmentGroup.js +1 -2
- package/lib/commonjs/components/Attachment/FileAttachmentGroup.js.map +1 -1
- package/lib/commonjs/components/Attachment/Gallery.js +1 -1
- package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
- package/lib/commonjs/components/Message/MessageItemView/MessageContent.js +2 -2
- package/lib/commonjs/components/Message/MessageItemView/MessageContent.js.map +1 -1
- package/lib/commonjs/components/MessageList/MessageFlashList.js +40 -2
- package/lib/commonjs/components/MessageList/MessageFlashList.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/FileAttachmentGroup.js +1 -2
- package/lib/module/components/Attachment/FileAttachmentGroup.js.map +1 -1
- package/lib/module/components/Attachment/Gallery.js +1 -1
- package/lib/module/components/Attachment/Gallery.js.map +1 -1
- package/lib/module/components/Message/MessageItemView/MessageContent.js +2 -2
- package/lib/module/components/Message/MessageItemView/MessageContent.js.map +1 -1
- package/lib/module/components/MessageList/MessageFlashList.js +40 -2
- package/lib/module/components/MessageList/MessageFlashList.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/MessageList/MessageFlashList.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Attachment/FileAttachmentGroup.tsx +2 -2
- package/src/components/Attachment/Gallery.tsx +1 -1
- package/src/components/Message/MessageItemView/MessageContent.tsx +2 -2
- package/src/components/MessageList/MessageFlashList.tsx +55 -2
- package/src/version.json +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stream-chat-react-native-core",
|
|
3
3
|
"description": "The official React Native and Expo components for Stream Chat, a service for building chat applications",
|
|
4
|
-
"version": "9.5.
|
|
4
|
+
"version": "9.5.2-beta.2",
|
|
5
5
|
"author": {
|
|
6
6
|
"company": "Stream.io Inc",
|
|
7
7
|
"name": "Stream.io Inc"
|
|
@@ -17,7 +17,7 @@ export type FileAttachmentGroupPropsWithContext = Pick<MessageContextValue, 'fil
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
const FileAttachmentGroupWithContext = (props: FileAttachmentGroupPropsWithContext) => {
|
|
20
|
-
const { files,
|
|
20
|
+
const { files, styles: stylesProp = {} } = props;
|
|
21
21
|
const { Attachment } = useComponentsContext();
|
|
22
22
|
|
|
23
23
|
const {
|
|
@@ -32,7 +32,7 @@ const FileAttachmentGroupWithContext = (props: FileAttachmentGroupPropsWithConte
|
|
|
32
32
|
<View style={[styles.container, {}, container, stylesProp.container]}>
|
|
33
33
|
{files.map((file, index) => (
|
|
34
34
|
<View
|
|
35
|
-
key={`file-by-attachment-group-${
|
|
35
|
+
key={`file-by-attachment-group-${index}`}
|
|
36
36
|
style={[styles.item, stylesProp.attachmentContainer, attachmentContainer]}
|
|
37
37
|
>
|
|
38
38
|
<Attachment attachment={file} />
|
|
@@ -272,7 +272,7 @@ const GalleryThumbnail = ({
|
|
|
272
272
|
accessibilityLabel={thumbnailAccessibilityLabel}
|
|
273
273
|
accessibilityRole='button'
|
|
274
274
|
disabled={preventPress}
|
|
275
|
-
key={`gallery-item-${
|
|
275
|
+
key={`gallery-item-${colIndex}/${rowIndex}`}
|
|
276
276
|
ref={thumbnailRef}
|
|
277
277
|
onLongPress={(event) => {
|
|
278
278
|
if (onLongPress) {
|
|
@@ -281,7 +281,7 @@ const MessageContentWithContext = (props: MessageContentPropsWithContext) => {
|
|
|
281
281
|
);
|
|
282
282
|
case 'attachments':
|
|
283
283
|
return otherAttachments.map((attachment, attachmentIndex) => (
|
|
284
|
-
<Attachment attachment={attachment} key={
|
|
284
|
+
<Attachment attachment={attachment} key={`attachment-${attachmentIndex}`} />
|
|
285
285
|
));
|
|
286
286
|
case 'files':
|
|
287
287
|
return (
|
|
@@ -297,7 +297,7 @@ const MessageContentWithContext = (props: MessageContentPropsWithContext) => {
|
|
|
297
297
|
const pollId = message.poll_id;
|
|
298
298
|
const poll = pollId && client.polls.fromState(pollId);
|
|
299
299
|
return pollId && poll ? (
|
|
300
|
-
<Poll key={`poll_${
|
|
300
|
+
<Poll key={`poll_${messageContentOrderIndex}`} message={message} poll={poll} />
|
|
301
301
|
) : null;
|
|
302
302
|
}
|
|
303
303
|
case 'location':
|
|
@@ -55,9 +55,11 @@ import { mergeThemes, useTheme } from '../../contexts/themeContext/ThemeContext'
|
|
|
55
55
|
import { ThreadContextValue, useThreadContext } from '../../contexts/threadContext/ThreadContext';
|
|
56
56
|
|
|
57
57
|
import { useStableCallback, useStateStore } from '../../hooks';
|
|
58
|
+
import { isVideoPlayerAvailable } from '../../native';
|
|
58
59
|
import { bumpOverlayLayoutRevision, useHasActiveId } from '../../state-store';
|
|
59
60
|
import { MessageInputHeightState } from '../../state-store/message-input-height-store';
|
|
60
61
|
import { primitives } from '../../theme';
|
|
62
|
+
import { FileTypes } from '../../types/types';
|
|
61
63
|
import { transitions } from '../../utils/animations/transitions';
|
|
62
64
|
import { MessageWrapper } from '../Message/MessageItemView/MessageWrapper';
|
|
63
65
|
import { excludeCanceledUploadNotifications } from '../Notifications/notificationFilters';
|
|
@@ -222,10 +224,61 @@ type MessageFlashListPropsWithContext = Pick<
|
|
|
222
224
|
|
|
223
225
|
const WAIT_FOR_SCROLL_TIMEOUT = 0;
|
|
224
226
|
|
|
227
|
+
// Classify an attachment bearing message by its primary shape so FlashList only
|
|
228
|
+
// recycles same shaped cells (means less work to rerender). Gallery/media is the
|
|
229
|
+
// heaviest subtree to mount, so we short circuit to it as soon as we see one gallery
|
|
230
|
+
// image/video nad this keeps gallery cells recycling only with other gallery cells,
|
|
231
|
+
// so the Gallery subtree reconciles on rebind instead of unmount & remount. Mirrors
|
|
232
|
+
// the attachment categorization in Message.
|
|
233
|
+
const getAttachmentItemType = (message: LocalMessage) => {
|
|
234
|
+
const attachments = message.attachments ?? [];
|
|
235
|
+
let hasGiphy = false;
|
|
236
|
+
let hasAudio = false;
|
|
237
|
+
let hasFile = false;
|
|
238
|
+
let hasCard = false;
|
|
239
|
+
for (const attachment of attachments) {
|
|
240
|
+
const isGalleryImage =
|
|
241
|
+
attachment.type === FileTypes.Image &&
|
|
242
|
+
!attachment.og_scrape_url &&
|
|
243
|
+
!attachment.title_link &&
|
|
244
|
+
(!!attachment.image_url || !!attachment.thumb_url);
|
|
245
|
+
const isGalleryVideo =
|
|
246
|
+
attachment.type === FileTypes.Video && !attachment.og_scrape_url && isVideoPlayerAvailable();
|
|
247
|
+
if (isGalleryImage || isGalleryVideo) {
|
|
248
|
+
return 'message-with-gallery';
|
|
249
|
+
}
|
|
250
|
+
if (attachment.type === FileTypes.Giphy) {
|
|
251
|
+
hasGiphy = true;
|
|
252
|
+
} else if (
|
|
253
|
+
attachment.type === FileTypes.Audio ||
|
|
254
|
+
attachment.type === FileTypes.VoiceRecording
|
|
255
|
+
) {
|
|
256
|
+
hasAudio = true;
|
|
257
|
+
} else if (attachment.type === FileTypes.File) {
|
|
258
|
+
hasFile = true;
|
|
259
|
+
} else if (attachment.og_scrape_url || attachment.title_link) {
|
|
260
|
+
hasCard = true;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (hasGiphy) {
|
|
264
|
+
return 'message-with-giphy';
|
|
265
|
+
}
|
|
266
|
+
if (hasAudio) {
|
|
267
|
+
return 'message-with-audio';
|
|
268
|
+
}
|
|
269
|
+
if (hasFile) {
|
|
270
|
+
return 'message-with-file';
|
|
271
|
+
}
|
|
272
|
+
if (hasCard) {
|
|
273
|
+
return 'message-with-card';
|
|
274
|
+
}
|
|
275
|
+
return 'message-with-attachments';
|
|
276
|
+
};
|
|
277
|
+
|
|
225
278
|
const getItemTypeInternal = (message: LocalMessage) => {
|
|
226
279
|
if (message.type === 'regular') {
|
|
227
280
|
if ((message.attachments?.length ?? 0) > 0) {
|
|
228
|
-
return
|
|
281
|
+
return getAttachmentItemType(message);
|
|
229
282
|
}
|
|
230
283
|
|
|
231
284
|
if (message.poll_id) {
|
|
@@ -1079,7 +1132,7 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
|
|
|
1079
1132
|
<FlashList
|
|
1080
1133
|
contentContainerStyle={flatListContentContainerStyle}
|
|
1081
1134
|
data={processedMessageList}
|
|
1082
|
-
drawDistance={
|
|
1135
|
+
drawDistance={250}
|
|
1083
1136
|
getItemType={getItemTypeInternal}
|
|
1084
1137
|
keyboardShouldPersistTaps='handled'
|
|
1085
1138
|
keyExtractor={keyExtractor}
|
package/src/version.json
CHANGED