stream-chat-react-native-core 5.1.1-beta.1 → 5.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/Attachment/Card.js +29 -18
- package/lib/commonjs/components/Attachment/Card.js.map +1 -1
- package/lib/commonjs/components/Attachment/Gallery.js +16 -20
- package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
- package/lib/commonjs/components/Attachment/GalleryImage.js +34 -6
- package/lib/commonjs/components/Attachment/GalleryImage.js.map +1 -1
- package/lib/commonjs/components/Attachment/Giphy.js +37 -29
- package/lib/commonjs/components/Attachment/Giphy.js.map +1 -1
- package/lib/commonjs/components/Avatar/Avatar.js +10 -8
- package/lib/commonjs/components/Avatar/Avatar.js.map +1 -1
- package/lib/commonjs/components/Avatar/GroupAvatar.js +3 -1
- package/lib/commonjs/components/Avatar/GroupAvatar.js.map +1 -1
- package/lib/commonjs/components/ChannelList/ChannelListMessenger.js +32 -15
- package/lib/commonjs/components/ChannelList/ChannelListMessenger.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/ChannelAvatar.js +30 -6
- package/lib/commonjs/components/ChannelPreview/ChannelAvatar.js.map +1 -1
- package/lib/commonjs/components/Chat/Chat.js +20 -5
- package/lib/commonjs/components/Chat/Chat.js.map +1 -1
- package/lib/commonjs/components/Chat/hooks/useCreateChatContext.js +2 -0
- package/lib/commonjs/components/Chat/hooks/useCreateChatContext.js.map +1 -1
- package/lib/commonjs/components/ImageBackground.js +64 -0
- package/lib/commonjs/components/ImageBackground.js.map +1 -0
- package/lib/commonjs/components/Message/Message.js +15 -16
- package/lib/commonjs/components/Message/Message.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageAvatar.js +12 -4
- package/lib/commonjs/components/Message/MessageSimple/MessageAvatar.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageRepliesAvatars.js +26 -5
- package/lib/commonjs/components/Message/MessageSimple/MessageRepliesAvatars.js.map +1 -1
- package/lib/commonjs/components/MessageList/MessageList.js +39 -26
- package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
- package/lib/commonjs/components/MessageOverlay/MessageOverlay.js +58 -47
- package/lib/commonjs/components/MessageOverlay/MessageOverlay.js.map +1 -1
- package/lib/commonjs/components/MessageOverlay/OverlayReactions.js +19 -19
- package/lib/commonjs/components/MessageOverlay/OverlayReactions.js.map +1 -1
- package/lib/commonjs/contexts/chatContext/ChatContext.js +2 -2
- package/lib/commonjs/contexts/chatContext/ChatContext.js.map +1 -1
- package/lib/commonjs/contexts/debugContext/DebugContext.js +63 -0
- package/lib/commonjs/contexts/debugContext/DebugContext.js.map +1 -0
- package/lib/commonjs/contexts/index.js +13 -0
- package/lib/commonjs/contexts/index.js.map +1 -1
- package/lib/commonjs/contexts/messageOverlayContext/MessageOverlayContext.js +2 -2
- package/lib/commonjs/contexts/messageOverlayContext/MessageOverlayContext.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/Card.js +29 -18
- package/lib/module/components/Attachment/Card.js.map +1 -1
- package/lib/module/components/Attachment/Gallery.js +16 -20
- package/lib/module/components/Attachment/Gallery.js.map +1 -1
- package/lib/module/components/Attachment/GalleryImage.js +34 -6
- package/lib/module/components/Attachment/GalleryImage.js.map +1 -1
- package/lib/module/components/Attachment/Giphy.js +37 -29
- package/lib/module/components/Attachment/Giphy.js.map +1 -1
- package/lib/module/components/Avatar/Avatar.js +10 -8
- package/lib/module/components/Avatar/Avatar.js.map +1 -1
- package/lib/module/components/Avatar/GroupAvatar.js +3 -1
- package/lib/module/components/Avatar/GroupAvatar.js.map +1 -1
- package/lib/module/components/ChannelList/ChannelListMessenger.js +32 -15
- package/lib/module/components/ChannelList/ChannelListMessenger.js.map +1 -1
- package/lib/module/components/ChannelPreview/ChannelAvatar.js +30 -6
- package/lib/module/components/ChannelPreview/ChannelAvatar.js.map +1 -1
- package/lib/module/components/Chat/Chat.js +20 -5
- package/lib/module/components/Chat/Chat.js.map +1 -1
- package/lib/module/components/Chat/hooks/useCreateChatContext.js +2 -0
- package/lib/module/components/Chat/hooks/useCreateChatContext.js.map +1 -1
- package/lib/module/components/ImageBackground.js +64 -0
- package/lib/module/components/ImageBackground.js.map +1 -0
- package/lib/module/components/Message/Message.js +15 -16
- package/lib/module/components/Message/Message.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageAvatar.js +12 -4
- package/lib/module/components/Message/MessageSimple/MessageAvatar.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageRepliesAvatars.js +26 -5
- package/lib/module/components/Message/MessageSimple/MessageRepliesAvatars.js.map +1 -1
- package/lib/module/components/MessageList/MessageList.js +39 -26
- package/lib/module/components/MessageList/MessageList.js.map +1 -1
- package/lib/module/components/MessageOverlay/MessageOverlay.js +58 -47
- package/lib/module/components/MessageOverlay/MessageOverlay.js.map +1 -1
- package/lib/module/components/MessageOverlay/OverlayReactions.js +19 -19
- package/lib/module/components/MessageOverlay/OverlayReactions.js.map +1 -1
- package/lib/module/contexts/chatContext/ChatContext.js +2 -2
- package/lib/module/contexts/chatContext/ChatContext.js.map +1 -1
- package/lib/module/contexts/debugContext/DebugContext.js +63 -0
- package/lib/module/contexts/debugContext/DebugContext.js.map +1 -0
- package/lib/module/contexts/index.js +13 -0
- package/lib/module/contexts/index.js.map +1 -1
- package/lib/module/contexts/messageOverlayContext/MessageOverlayContext.js +2 -2
- package/lib/module/contexts/messageOverlayContext/MessageOverlayContext.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Attachment/Card.d.ts +3 -2
- package/lib/typescript/components/Attachment/GalleryImage.d.ts +8 -2
- package/lib/typescript/components/Attachment/Giphy.d.ts +2 -1
- package/lib/typescript/components/Avatar/Avatar.d.ts +2 -1
- package/lib/typescript/components/Avatar/GroupAvatar.d.ts +2 -1
- package/lib/typescript/components/ChannelPreview/ChannelAvatar.d.ts +2 -0
- package/lib/typescript/components/Chat/Chat.d.ts +1 -1
- package/lib/typescript/components/Chat/hooks/useCreateChatContext.d.ts +1 -1
- package/lib/typescript/components/ImageBackground.d.ts +33 -0
- package/lib/typescript/components/Message/Message.d.ts +2 -1
- package/lib/typescript/components/Message/MessageSimple/MessageAvatar.d.ts +2 -1
- package/lib/typescript/components/Message/MessageSimple/MessageRepliesAvatars.d.ts +2 -0
- package/lib/typescript/components/MessageOverlay/OverlayReactions.d.ts +1 -0
- package/lib/typescript/contexts/chatContext/ChatContext.d.ts +3 -1
- package/lib/typescript/contexts/debugContext/DebugContext.d.ts +27 -0
- package/lib/typescript/contexts/index.d.ts +1 -0
- package/lib/typescript/contexts/messageOverlayContext/MessageOverlayContext.d.ts +4 -0
- package/package.json +2 -2
- package/src/components/Attachment/Card.tsx +11 -2
- package/src/components/Attachment/Gallery.tsx +1 -7
- package/src/components/Attachment/GalleryImage.tsx +31 -9
- package/src/components/Attachment/Giphy.tsx +8 -2
- package/src/components/Avatar/Avatar.tsx +12 -2
- package/src/components/Avatar/GroupAvatar.tsx +4 -4
- package/src/components/ChannelList/ChannelListMessenger.tsx +17 -0
- package/src/components/ChannelList/hooks/listeners/__tests__/useChannelUpdated.test.tsx +2 -1
- package/src/components/ChannelPreview/ChannelAvatar.tsx +23 -4
- package/src/components/Chat/Chat.tsx +111 -95
- package/src/components/Chat/hooks/useCreateChatContext.ts +2 -0
- package/src/components/ImageBackground.tsx +77 -0
- package/src/components/Message/Message.tsx +8 -8
- package/src/components/Message/MessageSimple/MessageAvatar.tsx +6 -2
- package/src/components/Message/MessageSimple/MessageRepliesAvatars.tsx +15 -3
- package/src/components/MessageList/MessageList.tsx +15 -0
- package/src/components/MessageOverlay/MessageOverlay.tsx +210 -205
- package/src/components/MessageOverlay/OverlayReactions.tsx +1 -0
- package/src/contexts/chatContext/ChatContext.tsx +3 -1
- package/src/contexts/debugContext/DebugContext.tsx +77 -0
- package/src/contexts/index.ts +1 -0
- package/src/contexts/messageOverlayContext/MessageOverlayContext.tsx +8 -1
- package/src/version.json +1 -1
|
@@ -24,6 +24,7 @@ import { MessageActionList as DefaultMessageActionList } from './MessageActionLi
|
|
|
24
24
|
import { OverlayReactionList as OverlayReactionListDefault } from './OverlayReactionList';
|
|
25
25
|
import { OverlayReactionsAvatar as OverlayReactionsAvatarDefault } from './OverlayReactionsAvatar';
|
|
26
26
|
|
|
27
|
+
import { ChatProvider } from '../../contexts/chatContext/ChatContext';
|
|
27
28
|
import { MessageProvider } from '../../contexts/messageContext/MessageContext';
|
|
28
29
|
import {
|
|
29
30
|
MessageOverlayContextValue,
|
|
@@ -118,6 +119,7 @@ const MessageOverlayWithContext = <
|
|
|
118
119
|
groupStyles,
|
|
119
120
|
handleReaction,
|
|
120
121
|
images,
|
|
122
|
+
chatContext,
|
|
121
123
|
message,
|
|
122
124
|
messageActions,
|
|
123
125
|
MessageActionList = DefaultMessageActionList,
|
|
@@ -301,219 +303,222 @@ const MessageOverlayWithContext = <
|
|
|
301
303
|
const { Attachment, FileAttachmentGroup, Gallery, MessageAvatar, Reply } = messagesContext || {};
|
|
302
304
|
|
|
303
305
|
return (
|
|
304
|
-
<
|
|
305
|
-
<
|
|
306
|
-
<
|
|
307
|
-
<
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
<PanGestureHandler
|
|
312
|
-
enabled={overlay === 'message'}
|
|
313
|
-
maxPointers={1}
|
|
314
|
-
minDist={10}
|
|
315
|
-
onGestureEvent={onPan}
|
|
306
|
+
<ChatProvider value={chatContext}>
|
|
307
|
+
<MessagesProvider value={messagesContext}>
|
|
308
|
+
<MessageProvider value={messageContext}>
|
|
309
|
+
<ThemeProvider mergedStyle={wrapMessageInTheme ? modifiedTheme : theme}>
|
|
310
|
+
<Animated.View
|
|
311
|
+
pointerEvents={'auto'}
|
|
312
|
+
style={[StyleSheet.absoluteFillObject, containerStyle]}
|
|
316
313
|
>
|
|
317
|
-
<
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}
|
|
343
|
-
showScreen={showScreen}
|
|
344
|
-
/>
|
|
345
|
-
) : null}
|
|
346
|
-
<Animated.View
|
|
347
|
-
onLayout={({
|
|
348
|
-
nativeEvent: {
|
|
349
|
-
layout: { height: layoutHeight, width: layoutWidth, x, y },
|
|
350
|
-
},
|
|
351
|
-
}) => {
|
|
352
|
-
messageLayout.value = {
|
|
353
|
-
x: alignment === 'left' ? x + layoutWidth : x,
|
|
354
|
-
y,
|
|
355
|
-
};
|
|
356
|
-
messageWidth.value = layoutWidth;
|
|
357
|
-
messageHeight.value = layoutHeight;
|
|
358
|
-
}}
|
|
359
|
-
style={[styles.alignEnd, styles.row, showScreenStyle]}
|
|
314
|
+
<PanGestureHandler
|
|
315
|
+
enabled={overlay === 'message'}
|
|
316
|
+
maxPointers={1}
|
|
317
|
+
minDist={10}
|
|
318
|
+
onGestureEvent={onPan}
|
|
319
|
+
>
|
|
320
|
+
<Animated.View style={[StyleSheet.absoluteFillObject]}>
|
|
321
|
+
<SafeAreaView style={styles.flex}>
|
|
322
|
+
<TapGestureHandler
|
|
323
|
+
maxDist={32}
|
|
324
|
+
onHandlerStateChange={({ nativeEvent: { state } }) => {
|
|
325
|
+
if (state === State.END) {
|
|
326
|
+
setOverlay('none');
|
|
327
|
+
}
|
|
328
|
+
}}
|
|
329
|
+
>
|
|
330
|
+
<Animated.View style={[styles.flex, panStyle]}>
|
|
331
|
+
{message && (
|
|
332
|
+
<View
|
|
333
|
+
style={[
|
|
334
|
+
styles.center,
|
|
335
|
+
styles.overlayPadding,
|
|
336
|
+
{ padding: overlayPadding },
|
|
337
|
+
alignment === 'left' ? styles.alignStart : styles.alignEnd,
|
|
338
|
+
]}
|
|
360
339
|
>
|
|
361
|
-
{
|
|
362
|
-
<
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
? !message.quoted_message
|
|
375
|
-
? transparent
|
|
376
|
-
: grey_gainsboro
|
|
377
|
-
: blue_alice
|
|
378
|
-
: alignment === 'left'
|
|
379
|
-
? white_smoke
|
|
380
|
-
: grey_gainsboro,
|
|
381
|
-
borderBottomLeftRadius:
|
|
382
|
-
(groupStyle === 'left_bottom' ||
|
|
383
|
-
groupStyle === 'left_single') &&
|
|
384
|
-
(!hasThreadReplies || threadList)
|
|
385
|
-
? borderRadiusS
|
|
386
|
-
: borderRadiusL,
|
|
387
|
-
borderBottomRightRadius:
|
|
388
|
-
(groupStyle === 'right_bottom' ||
|
|
389
|
-
groupStyle === 'right_single') &&
|
|
390
|
-
(!hasThreadReplies || threadList)
|
|
391
|
-
? borderRadiusS
|
|
392
|
-
: borderRadiusL,
|
|
393
|
-
borderColor: grey_whisper,
|
|
340
|
+
{handleReaction && ownCapabilities?.sendReaction ? (
|
|
341
|
+
<OverlayReactionList
|
|
342
|
+
messageLayout={messageLayout}
|
|
343
|
+
ownReactionTypes={
|
|
344
|
+
message?.own_reactions?.map((reaction) => reaction.type) || []
|
|
345
|
+
}
|
|
346
|
+
showScreen={showScreen}
|
|
347
|
+
/>
|
|
348
|
+
) : null}
|
|
349
|
+
<Animated.View
|
|
350
|
+
onLayout={({
|
|
351
|
+
nativeEvent: {
|
|
352
|
+
layout: { height: layoutHeight, width: layoutWidth, x, y },
|
|
394
353
|
},
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
:
|
|
398
|
-
|
|
399
|
-
|
|
354
|
+
}) => {
|
|
355
|
+
messageLayout.value = {
|
|
356
|
+
x: alignment === 'left' ? x + layoutWidth : x,
|
|
357
|
+
y,
|
|
358
|
+
};
|
|
359
|
+
messageWidth.value = layoutWidth;
|
|
360
|
+
messageHeight.value = layoutHeight;
|
|
361
|
+
}}
|
|
362
|
+
style={[styles.alignEnd, styles.row, showScreenStyle]}
|
|
400
363
|
>
|
|
401
|
-
{
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
364
|
+
{alignment === 'left' && MessageAvatar && (
|
|
365
|
+
<MessageAvatar {...{ alignment, message, showAvatar: true }} />
|
|
366
|
+
)}
|
|
367
|
+
<View
|
|
368
|
+
pointerEvents='none'
|
|
369
|
+
style={[
|
|
370
|
+
styles.containerInner,
|
|
371
|
+
{
|
|
372
|
+
backgroundColor:
|
|
373
|
+
onlyEmojis && !message.quoted_message
|
|
374
|
+
? transparent
|
|
375
|
+
: otherAttachments?.length
|
|
376
|
+
? otherAttachments[0].type === 'giphy'
|
|
377
|
+
? !message.quoted_message
|
|
378
|
+
? transparent
|
|
379
|
+
: grey_gainsboro
|
|
380
|
+
: blue_alice
|
|
381
|
+
: alignment === 'left'
|
|
382
|
+
? white_smoke
|
|
383
|
+
: grey_gainsboro,
|
|
384
|
+
borderBottomLeftRadius:
|
|
385
|
+
(groupStyle === 'left_bottom' ||
|
|
386
|
+
groupStyle === 'left_single') &&
|
|
387
|
+
(!hasThreadReplies || threadList)
|
|
388
|
+
? borderRadiusS
|
|
389
|
+
: borderRadiusL,
|
|
390
|
+
borderBottomRightRadius:
|
|
391
|
+
(groupStyle === 'right_bottom' ||
|
|
392
|
+
groupStyle === 'right_single') &&
|
|
393
|
+
(!hasThreadReplies || threadList)
|
|
394
|
+
? borderRadiusS
|
|
395
|
+
: borderRadiusL,
|
|
396
|
+
borderColor: grey_whisper,
|
|
397
|
+
},
|
|
398
|
+
(onlyEmojis && !message.quoted_message) ||
|
|
399
|
+
otherAttachments?.length
|
|
400
|
+
? { borderWidth: 0 }
|
|
401
|
+
: {},
|
|
402
|
+
containerInner,
|
|
403
|
+
]}
|
|
404
|
+
>
|
|
405
|
+
{messagesContext?.messageContentOrder?.map(
|
|
406
|
+
(messageContentType, messageContentOrderIndex) => {
|
|
407
|
+
switch (messageContentType) {
|
|
408
|
+
case 'quoted_reply':
|
|
409
|
+
return (
|
|
410
|
+
message.quoted_message &&
|
|
411
|
+
Reply && (
|
|
412
|
+
<View
|
|
413
|
+
key={`quoted_reply_${messageContentOrderIndex}`}
|
|
414
|
+
style={[styles.replyContainer, replyContainer]}
|
|
415
|
+
>
|
|
416
|
+
<Reply
|
|
417
|
+
quotedMessage={
|
|
418
|
+
message.quoted_message as ReplyProps<StreamChatGenerics>['quotedMessage']
|
|
419
|
+
}
|
|
420
|
+
styles={{
|
|
421
|
+
messageContainer: {
|
|
422
|
+
maxWidth: vw(60),
|
|
423
|
+
},
|
|
424
|
+
}}
|
|
425
|
+
/>
|
|
426
|
+
</View>
|
|
427
|
+
)
|
|
428
|
+
);
|
|
429
|
+
case 'attachments':
|
|
430
|
+
return otherAttachments?.map(
|
|
431
|
+
(attachment, attachmentIndex) =>
|
|
432
|
+
Attachment && (
|
|
433
|
+
<Attachment
|
|
434
|
+
attachment={attachment}
|
|
435
|
+
key={`${message.id}-${attachmentIndex}`}
|
|
436
|
+
/>
|
|
437
|
+
),
|
|
438
|
+
);
|
|
439
|
+
case 'files':
|
|
440
|
+
return (
|
|
441
|
+
FileAttachmentGroup && (
|
|
442
|
+
<FileAttachmentGroup
|
|
443
|
+
files={files}
|
|
444
|
+
key={`file_attachment_group_${messageContentOrderIndex}`}
|
|
445
|
+
messageId={message.id}
|
|
421
446
|
/>
|
|
422
|
-
|
|
423
|
-
)
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
447
|
+
)
|
|
448
|
+
);
|
|
449
|
+
case 'gallery':
|
|
450
|
+
return (
|
|
451
|
+
Gallery && (
|
|
452
|
+
<Gallery
|
|
453
|
+
alignment={alignment}
|
|
454
|
+
groupStyles={groupStyles}
|
|
455
|
+
hasThreadReplies={!!message?.reply_count}
|
|
456
|
+
images={images}
|
|
457
|
+
key={`gallery_${messageContentOrderIndex}`}
|
|
458
|
+
message={message}
|
|
459
|
+
threadList={threadList}
|
|
460
|
+
videos={videos}
|
|
432
461
|
/>
|
|
433
|
-
)
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
key={`
|
|
441
|
-
messageId={message.id}
|
|
442
|
-
/>
|
|
443
|
-
)
|
|
444
|
-
);
|
|
445
|
-
case 'gallery':
|
|
446
|
-
return (
|
|
447
|
-
Gallery && (
|
|
448
|
-
<Gallery
|
|
449
|
-
alignment={alignment}
|
|
450
|
-
groupStyles={groupStyles}
|
|
451
|
-
hasThreadReplies={!!message?.reply_count}
|
|
452
|
-
images={images}
|
|
453
|
-
key={`gallery_${messageContentOrderIndex}`}
|
|
462
|
+
)
|
|
463
|
+
);
|
|
464
|
+
case 'text':
|
|
465
|
+
default:
|
|
466
|
+
return otherAttachments?.length &&
|
|
467
|
+
otherAttachments[0].actions ? null : (
|
|
468
|
+
<MessageTextContainer<StreamChatGenerics>
|
|
469
|
+
key={`message_text_container_${messageContentOrderIndex}`}
|
|
454
470
|
message={message}
|
|
455
|
-
|
|
456
|
-
|
|
471
|
+
messageOverlay
|
|
472
|
+
messageTextNumberOfLines={messageTextNumberOfLines}
|
|
473
|
+
onlyEmojis={onlyEmojis}
|
|
457
474
|
/>
|
|
458
|
-
)
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
) : null}
|
|
506
|
-
</View>
|
|
507
|
-
)}
|
|
508
|
-
</Animated.View>
|
|
509
|
-
</TapGestureHandler>
|
|
510
|
-
</SafeAreaView>
|
|
511
|
-
</Animated.View>
|
|
512
|
-
</PanGestureHandler>
|
|
513
|
-
</Animated.View>
|
|
514
|
-
</ThemeProvider>
|
|
515
|
-
</MessageProvider>
|
|
516
|
-
</MessagesProvider>
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
)}
|
|
479
|
+
</View>
|
|
480
|
+
</Animated.View>
|
|
481
|
+
{messageActions && (
|
|
482
|
+
<MessageActionList
|
|
483
|
+
MessageActionListItem={MessageActionListItem}
|
|
484
|
+
showScreen={showScreen}
|
|
485
|
+
{...messageActionProps}
|
|
486
|
+
message={message}
|
|
487
|
+
/>
|
|
488
|
+
)}
|
|
489
|
+
{!!messageReactionTitle &&
|
|
490
|
+
message.latest_reactions &&
|
|
491
|
+
message.latest_reactions.length > 0 ? (
|
|
492
|
+
<OverlayReactions
|
|
493
|
+
alignment={alignment}
|
|
494
|
+
OverlayReactionsAvatar={OverlayReactionsAvatar}
|
|
495
|
+
reactions={
|
|
496
|
+
message.latest_reactions.map((reaction) => ({
|
|
497
|
+
alignment:
|
|
498
|
+
clientId && clientId === reaction.user?.id ? 'right' : 'left',
|
|
499
|
+
id: reaction?.user?.id || '',
|
|
500
|
+
image: reaction?.user?.image,
|
|
501
|
+
name: reaction?.user?.name || reaction.user_id || '',
|
|
502
|
+
type: reaction.type,
|
|
503
|
+
})) as Reaction[]
|
|
504
|
+
}
|
|
505
|
+
showScreen={showScreen}
|
|
506
|
+
supportedReactions={messagesContext?.supportedReactions}
|
|
507
|
+
title={messageReactionTitle}
|
|
508
|
+
/>
|
|
509
|
+
) : null}
|
|
510
|
+
</View>
|
|
511
|
+
)}
|
|
512
|
+
</Animated.View>
|
|
513
|
+
</TapGestureHandler>
|
|
514
|
+
</SafeAreaView>
|
|
515
|
+
</Animated.View>
|
|
516
|
+
</PanGestureHandler>
|
|
517
|
+
</Animated.View>
|
|
518
|
+
</ThemeProvider>
|
|
519
|
+
</MessageProvider>
|
|
520
|
+
</MessagesProvider>
|
|
521
|
+
</ChatProvider>
|
|
517
522
|
);
|
|
518
523
|
};
|
|
519
524
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useContext } from 'react';
|
|
2
|
+
import type { ImageProps } from 'react-native';
|
|
2
3
|
|
|
3
4
|
import type { AppSettingsAPIResponse, Channel, EventHandler, Mute, StreamChat } from 'stream-chat';
|
|
4
5
|
|
|
@@ -34,6 +35,7 @@ export type ChatContextValue<
|
|
|
34
35
|
client: StreamChat<StreamChatGenerics>;
|
|
35
36
|
connectionRecovering: boolean;
|
|
36
37
|
enableOfflineSupport: boolean;
|
|
38
|
+
ImageComponent: React.ComponentType<ImageProps>;
|
|
37
39
|
isOnline: boolean;
|
|
38
40
|
mutedUsers: Mute<StreamChatGenerics>[];
|
|
39
41
|
/**
|
|
@@ -71,7 +73,7 @@ export const ChatProvider = <
|
|
|
71
73
|
children,
|
|
72
74
|
value,
|
|
73
75
|
}: PropsWithChildren<{
|
|
74
|
-
value
|
|
76
|
+
value?: ChatContextValue<StreamChatGenerics>;
|
|
75
77
|
}>) => (
|
|
76
78
|
<ChatContext.Provider value={value as unknown as ChatContextValue}>
|
|
77
79
|
{children}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, { PropsWithChildren, useContext, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { Channel, ChannelState, StreamChat } from 'stream-chat';
|
|
4
|
+
|
|
5
|
+
import type { MessageType } from '../../components/MessageList/hooks/useMessageList';
|
|
6
|
+
import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
7
|
+
|
|
8
|
+
import { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';
|
|
9
|
+
|
|
10
|
+
export type DebugDataType<
|
|
11
|
+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
12
|
+
> =
|
|
13
|
+
| StreamChat<StreamChatGenerics>['user']
|
|
14
|
+
| {
|
|
15
|
+
data: Channel<StreamChatGenerics>['data'];
|
|
16
|
+
members: ChannelState<StreamChatGenerics>['members'];
|
|
17
|
+
}[]
|
|
18
|
+
| MessageType<StreamChatGenerics>[];
|
|
19
|
+
|
|
20
|
+
export type DebugContextValue<
|
|
21
|
+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
22
|
+
> = {
|
|
23
|
+
eventType?: string;
|
|
24
|
+
sendEventParams?: {
|
|
25
|
+
action: string;
|
|
26
|
+
data: DebugDataType<StreamChatGenerics>;
|
|
27
|
+
};
|
|
28
|
+
setEventType?: (data: string) => void;
|
|
29
|
+
setSendEventParams?: (data: { action: string; data: DebugDataType<StreamChatGenerics> }) => void;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const DebugContext = React.createContext(
|
|
33
|
+
DEFAULT_BASE_CONTEXT_VALUE as React.MutableRefObject<DebugContextValue>,
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
export const DebugContextProvider = <
|
|
37
|
+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
38
|
+
>({
|
|
39
|
+
children,
|
|
40
|
+
useFlipper,
|
|
41
|
+
}: PropsWithChildren<{
|
|
42
|
+
useFlipper: () => {
|
|
43
|
+
updateData: (ref: React.RefObject<DebugContextValue<StreamChatGenerics>>) => void;
|
|
44
|
+
};
|
|
45
|
+
}>) => {
|
|
46
|
+
const debugRef = useRef<DebugContextValue<StreamChatGenerics>>({
|
|
47
|
+
eventType: undefined,
|
|
48
|
+
sendEventParams: undefined,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const { updateData } = useFlipper();
|
|
52
|
+
|
|
53
|
+
const ref = useRef<DebugContextValue<StreamChatGenerics>>({
|
|
54
|
+
setEventType: (data: string) => {
|
|
55
|
+
debugRef.current.eventType = data;
|
|
56
|
+
updateData(debugRef);
|
|
57
|
+
},
|
|
58
|
+
setSendEventParams: (data: { action: string; data: DebugDataType<StreamChatGenerics> }) => {
|
|
59
|
+
debugRef.current.sendEventParams = data;
|
|
60
|
+
updateData(debugRef);
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<DebugContext.Provider value={ref as unknown as React.MutableRefObject<DebugContextValue>}>
|
|
66
|
+
{children}
|
|
67
|
+
</DebugContext.Provider>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const useDebugContext = () => {
|
|
72
|
+
const contextValue = useContext(
|
|
73
|
+
DebugContext,
|
|
74
|
+
) as unknown as React.MutableRefObject<DebugContextValue>;
|
|
75
|
+
|
|
76
|
+
return contextValue;
|
|
77
|
+
};
|
package/src/contexts/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './attachmentPickerContext/AttachmentPickerContext';
|
|
|
2
2
|
export * from './channelContext/ChannelContext';
|
|
3
3
|
export * from './channelsContext/ChannelsContext';
|
|
4
4
|
export * from './chatContext/ChatContext';
|
|
5
|
+
export * from './debugContext/DebugContext';
|
|
5
6
|
export * from './imageGalleryContext/ImageGalleryContext';
|
|
6
7
|
export * from './keyboardContext/KeyboardContext';
|
|
7
8
|
export * from './messageContext/MessageContext';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useContext } from 'react';
|
|
2
2
|
|
|
3
|
+
import type { ImageProps } from 'react-native';
|
|
4
|
+
|
|
3
5
|
import type { Attachment, TranslationLanguages } from 'stream-chat';
|
|
4
6
|
|
|
5
7
|
import { useResettableState } from './hooks/useResettableState';
|
|
@@ -15,6 +17,7 @@ import type { OverlayReactionsProps } from '../../components/MessageOverlay/Over
|
|
|
15
17
|
import type { OverlayReactionsAvatarProps } from '../../components/MessageOverlay/OverlayReactionsAvatar';
|
|
16
18
|
import type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';
|
|
17
19
|
import type { ReactionData } from '../../utils/utils';
|
|
20
|
+
import type { ChatContextValue } from '../chatContext/ChatContext';
|
|
18
21
|
import type { Alignment, MessageContextValue } from '../messageContext/MessageContext';
|
|
19
22
|
import type { MessagesContextValue } from '../messagesContext/MessagesContext';
|
|
20
23
|
import type { OwnCapabilitiesContextValue } from '../ownCapabilitiesContext/OwnCapabilitiesContext';
|
|
@@ -27,10 +30,12 @@ export type MessageOverlayData<
|
|
|
27
30
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
28
31
|
> = {
|
|
29
32
|
alignment?: Alignment;
|
|
33
|
+
chatContext?: ChatContextValue<StreamChatGenerics>;
|
|
30
34
|
clientId?: string;
|
|
31
35
|
files?: Attachment<StreamChatGenerics>[];
|
|
32
36
|
groupStyles?: GroupType[];
|
|
33
37
|
handleReaction?: (reactionType: string) => Promise<void>;
|
|
38
|
+
ImageComponent?: React.ComponentType<ImageProps>;
|
|
34
39
|
images?: Attachment<StreamChatGenerics>[];
|
|
35
40
|
message?: MessageType<StreamChatGenerics>;
|
|
36
41
|
messageActions?: MessageActionType[];
|
|
@@ -89,7 +94,9 @@ export const MessageOverlayProvider = <
|
|
|
89
94
|
}>) => {
|
|
90
95
|
const messageOverlayContext = useResettableState(value);
|
|
91
96
|
return (
|
|
92
|
-
<MessageOverlayContext.Provider
|
|
97
|
+
<MessageOverlayContext.Provider
|
|
98
|
+
value={messageOverlayContext as unknown as MessageOverlayContextValue}
|
|
99
|
+
>
|
|
93
100
|
{children}
|
|
94
101
|
</MessageOverlayContext.Provider>
|
|
95
102
|
);
|
package/src/version.json
CHANGED