stream-chat-react-native-core 9.2.1 → 9.2.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/Channel/Channel.js +18 -2
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateChannelContext.js +2 -0
- package/lib/commonjs/components/Channel/hooks/useCreateChannelContext.js.map +1 -1
- package/lib/commonjs/components/Message/MessageItemView/MessageContent.js +1 -2
- package/lib/commonjs/components/Message/MessageItemView/MessageContent.js.map +1 -1
- package/lib/commonjs/components/MessageList/MessageFlashList.js +47 -36
- package/lib/commonjs/components/MessageList/MessageFlashList.js.map +1 -1
- package/lib/commonjs/contexts/channelContext/ChannelContext.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Channel/Channel.js +18 -2
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateChannelContext.js +2 -0
- package/lib/module/components/Channel/hooks/useCreateChannelContext.js.map +1 -1
- package/lib/module/components/Message/MessageItemView/MessageContent.js +1 -2
- package/lib/module/components/Message/MessageItemView/MessageContent.js.map +1 -1
- package/lib/module/components/MessageList/MessageFlashList.js +47 -36
- package/lib/module/components/MessageList/MessageFlashList.js.map +1 -1
- package/lib/module/contexts/channelContext/ChannelContext.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Channel/Channel.d.ts.map +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateChannelContext.d.ts +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateChannelContext.d.ts.map +1 -1
- package/lib/typescript/components/MessageList/MessageFlashList.d.ts +1 -1
- package/lib/typescript/components/MessageList/MessageFlashList.d.ts.map +1 -1
- package/lib/typescript/contexts/channelContext/ChannelContext.d.ts +6 -0
- package/lib/typescript/contexts/channelContext/ChannelContext.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Channel/Channel.tsx +21 -6
- package/src/components/Channel/hooks/useCreateChannelContext.ts +2 -0
- package/src/components/Message/MessageItemView/MessageContent.tsx +0 -1
- package/src/components/MessageList/MessageFlashList.tsx +31 -25
- package/src/components/Thread/__tests__/__snapshots__/Thread.test.tsx.snap +0 -4
- package/src/contexts/channelContext/ChannelContext.tsx +6 -0
- package/src/version.json +1 -1
|
@@ -27,6 +27,7 @@ export const useCreateChannelContext = ({
|
|
|
27
27
|
setChannelUnreadState,
|
|
28
28
|
setLastRead,
|
|
29
29
|
setTargetedMessage,
|
|
30
|
+
hasPendingInitialTargetLoad,
|
|
30
31
|
targetedMessage,
|
|
31
32
|
threadList,
|
|
32
33
|
uploadAbortControllerRef,
|
|
@@ -69,6 +70,7 @@ export const useCreateChannelContext = ({
|
|
|
69
70
|
setChannelUnreadState,
|
|
70
71
|
setLastRead,
|
|
71
72
|
setTargetedMessage,
|
|
73
|
+
hasPendingInitialTargetLoad,
|
|
72
74
|
targetedMessage,
|
|
73
75
|
threadList,
|
|
74
76
|
uploadAbortControllerRef,
|
|
@@ -656,7 +656,6 @@ const styles = StyleSheet.create({
|
|
|
656
656
|
containerInner: {
|
|
657
657
|
borderTopLeftRadius: components.messageBubbleRadiusGroupBottom,
|
|
658
658
|
borderTopRightRadius: components.messageBubbleRadiusGroupBottom,
|
|
659
|
-
overflow: 'hidden',
|
|
660
659
|
},
|
|
661
660
|
contentBody: {
|
|
662
661
|
flexShrink: 1,
|
|
@@ -132,6 +132,7 @@ type MessageFlashListPropsWithContext = Pick<
|
|
|
132
132
|
| 'scrollToFirstUnreadThreshold'
|
|
133
133
|
| 'setChannelUnreadState'
|
|
134
134
|
| 'setTargetedMessage'
|
|
135
|
+
| 'hasPendingInitialTargetLoad'
|
|
135
136
|
| 'targetedMessage'
|
|
136
137
|
| 'threadList'
|
|
137
138
|
| 'maximumMessageLimit'
|
|
@@ -289,6 +290,7 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
|
|
|
289
290
|
setChannelUnreadState,
|
|
290
291
|
setFlatListRef,
|
|
291
292
|
setTargetedMessage,
|
|
293
|
+
hasPendingInitialTargetLoad,
|
|
292
294
|
targetedMessage,
|
|
293
295
|
thread,
|
|
294
296
|
threadInstance,
|
|
@@ -388,11 +390,15 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
|
|
|
388
390
|
|
|
389
391
|
useEffect(() => {
|
|
390
392
|
if (autoscrollToRecent && flashListRef.current) {
|
|
393
|
+
if (hasPendingInitialTargetLoad?.()) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
|
|
391
397
|
flashListRef.current.scrollToEnd({
|
|
392
398
|
animated: true,
|
|
393
399
|
});
|
|
394
400
|
}
|
|
395
|
-
}, [autoscrollToRecent]);
|
|
401
|
+
}, [autoscrollToRecent, hasPendingInitialTargetLoad]);
|
|
396
402
|
|
|
397
403
|
const maintainVisibleContentPosition = useMemo(() => {
|
|
398
404
|
return {
|
|
@@ -408,18 +414,6 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
|
|
|
408
414
|
}
|
|
409
415
|
}, [disabled]);
|
|
410
416
|
|
|
411
|
-
const indexToScrollToRef = useRef<number | undefined>(undefined);
|
|
412
|
-
|
|
413
|
-
const initialIndexToScrollTo = useMemo(() => {
|
|
414
|
-
return targetedMessage
|
|
415
|
-
? processedMessageList.findIndex((message) => message?.id === targetedMessage)
|
|
416
|
-
: -1;
|
|
417
|
-
}, [processedMessageList, targetedMessage]);
|
|
418
|
-
|
|
419
|
-
useEffect(() => {
|
|
420
|
-
indexToScrollToRef.current = initialIndexToScrollTo;
|
|
421
|
-
}, [initialIndexToScrollTo]);
|
|
422
|
-
|
|
423
417
|
/**
|
|
424
418
|
* Check if a messageId needs to be scrolled to after list loads, and scroll to it
|
|
425
419
|
* Note: This effect fires on every list change with a small debounce so that scrolling isnt abrupted by an immediate rerender
|
|
@@ -440,13 +434,29 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
|
|
|
440
434
|
scrollToDebounceTimeoutRef.current = setTimeout(() => {
|
|
441
435
|
clearTimeout(scrollToDebounceTimeoutRef.current);
|
|
442
436
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
437
|
+
const scrollToIndex = async () => {
|
|
438
|
+
const list = flashListRef.current;
|
|
439
|
+
|
|
440
|
+
if (!list) {
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
await list.scrollToIndex({
|
|
445
|
+
index: indexOfParentInMessageList,
|
|
446
|
+
animated: true,
|
|
447
|
+
viewPosition: 0.5,
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
return true;
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
requestAnimationFrame(async () => {
|
|
454
|
+
await scrollToIndex();
|
|
455
|
+
requestAnimationFrame(async () => {
|
|
456
|
+
await scrollToIndex();
|
|
457
|
+
setTargetedMessage(undefined);
|
|
458
|
+
});
|
|
448
459
|
});
|
|
449
|
-
setTargetedMessage(undefined);
|
|
450
460
|
}, WAIT_FOR_SCROLL_TIMEOUT);
|
|
451
461
|
}
|
|
452
462
|
}, [loadChannelAroundMessage, processedMessageList, setTargetedMessage, targetedMessage]);
|
|
@@ -456,8 +466,6 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
|
|
|
456
466
|
(message) => message?.id === messageId,
|
|
457
467
|
);
|
|
458
468
|
|
|
459
|
-
indexToScrollToRef.current = indexOfParentInMessageList;
|
|
460
|
-
|
|
461
469
|
try {
|
|
462
470
|
if (indexOfParentInMessageList === -1) {
|
|
463
471
|
clearTimeout(scrollToDebounceTimeoutRef.current);
|
|
@@ -529,7 +537,6 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
|
|
|
529
537
|
setScrollToBottomButtonVisible(true);
|
|
530
538
|
return;
|
|
531
539
|
} else {
|
|
532
|
-
indexToScrollToRef.current = undefined;
|
|
533
540
|
setAutoscrollToRecent(true);
|
|
534
541
|
}
|
|
535
542
|
const latestNonCurrentMessageBeforeUpdate = latestNonCurrentMessageBeforeUpdateRef.current;
|
|
@@ -1064,9 +1071,6 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
|
|
|
1064
1071
|
data={processedMessageList}
|
|
1065
1072
|
drawDistance={800}
|
|
1066
1073
|
getItemType={getItemTypeInternal}
|
|
1067
|
-
initialScrollIndex={
|
|
1068
|
-
indexToScrollToRef.current === -1 ? undefined : indexToScrollToRef.current
|
|
1069
|
-
}
|
|
1070
1074
|
keyboardShouldPersistTaps='handled'
|
|
1071
1075
|
keyExtractor={keyExtractor}
|
|
1072
1076
|
ListFooterComponent={ListFooterComponent}
|
|
@@ -1203,6 +1207,7 @@ export const MessageFlashList = (props: MessageFlashListProps) => {
|
|
|
1203
1207
|
scrollToFirstUnreadThreshold,
|
|
1204
1208
|
setChannelUnreadState,
|
|
1205
1209
|
setTargetedMessage,
|
|
1210
|
+
hasPendingInitialTargetLoad,
|
|
1206
1211
|
targetedMessage,
|
|
1207
1212
|
threadList,
|
|
1208
1213
|
} = useChannelContext();
|
|
@@ -1246,6 +1251,7 @@ export const MessageFlashList = (props: MessageFlashListProps) => {
|
|
|
1246
1251
|
scrollToFirstUnreadThreshold,
|
|
1247
1252
|
setChannelUnreadState,
|
|
1248
1253
|
setTargetedMessage,
|
|
1254
|
+
hasPendingInitialTargetLoad,
|
|
1249
1255
|
shouldShowUnreadUnderlay,
|
|
1250
1256
|
targetedMessage,
|
|
1251
1257
|
thread,
|
|
@@ -506,7 +506,6 @@ exports[`Thread should match thread snapshot 1`] = `
|
|
|
506
506
|
{
|
|
507
507
|
"borderTopLeftRadius": 20,
|
|
508
508
|
"borderTopRightRadius": 20,
|
|
509
|
-
"overflow": "hidden",
|
|
510
509
|
},
|
|
511
510
|
{
|
|
512
511
|
"backgroundColor": "#ebeef1",
|
|
@@ -849,7 +848,6 @@ exports[`Thread should match thread snapshot 1`] = `
|
|
|
849
848
|
{
|
|
850
849
|
"borderTopLeftRadius": 20,
|
|
851
850
|
"borderTopRightRadius": 20,
|
|
852
|
-
"overflow": "hidden",
|
|
853
851
|
},
|
|
854
852
|
{
|
|
855
853
|
"backgroundColor": "#ebeef1",
|
|
@@ -1225,7 +1223,6 @@ exports[`Thread should match thread snapshot 1`] = `
|
|
|
1225
1223
|
{
|
|
1226
1224
|
"borderTopLeftRadius": 20,
|
|
1227
1225
|
"borderTopRightRadius": 20,
|
|
1228
|
-
"overflow": "hidden",
|
|
1229
1226
|
},
|
|
1230
1227
|
{
|
|
1231
1228
|
"backgroundColor": "#ebeef1",
|
|
@@ -1559,7 +1556,6 @@ exports[`Thread should match thread snapshot 1`] = `
|
|
|
1559
1556
|
{
|
|
1560
1557
|
"borderTopLeftRadius": 20,
|
|
1561
1558
|
"borderTopRightRadius": 20,
|
|
1562
|
-
"overflow": "hidden",
|
|
1563
1559
|
},
|
|
1564
1560
|
{
|
|
1565
1561
|
"backgroundColor": "#ebeef1",
|
|
@@ -112,6 +112,12 @@ export type ChannelContextValue = {
|
|
|
112
112
|
setChannelUnreadState: (data: ChannelUnreadStateStoreType['channelUnreadState']) => void;
|
|
113
113
|
setLastRead: React.Dispatch<React.SetStateAction<Date | undefined>>;
|
|
114
114
|
setTargetedMessage: (messageId?: string) => void;
|
|
115
|
+
/**
|
|
116
|
+
* Returns true when Channel is about to load an initial targeted message.
|
|
117
|
+
*
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
120
|
+
hasPendingInitialTargetLoad?: () => boolean;
|
|
115
121
|
/**
|
|
116
122
|
* Abort controller for cancelling async requests made for uploading images/files
|
|
117
123
|
* Its a map of filename and AbortController
|
package/src/version.json
CHANGED