stream-chat-react-native-core 5.2.0 → 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/ChannelPreview/ChannelAvatar.js +30 -6
- package/lib/commonjs/components/ChannelPreview/ChannelAvatar.js.map +1 -1
- package/lib/commonjs/components/Chat/Chat.js +8 -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/MessageOverlay/MessageOverlay.js +58 -47
- package/lib/commonjs/components/MessageOverlay/MessageOverlay.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/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/ChannelPreview/ChannelAvatar.js +30 -6
- package/lib/module/components/ChannelPreview/ChannelAvatar.js.map +1 -1
- package/lib/module/components/Chat/Chat.js +8 -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/MessageOverlay/MessageOverlay.js +58 -47
- package/lib/module/components/MessageOverlay/MessageOverlay.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/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/contexts/chatContext/ChatContext.d.ts +3 -1
- package/lib/typescript/contexts/messageOverlayContext/MessageOverlayContext.d.ts +4 -0
- package/package.json +1 -1
- 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/hooks/listeners/__tests__/useChannelUpdated.test.tsx +2 -1
- package/src/components/ChannelPreview/ChannelAvatar.tsx +23 -4
- package/src/components/Chat/Chat.tsx +98 -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/MessageOverlay/MessageOverlay.tsx +210 -205
- package/src/contexts/chatContext/ChatContext.tsx +3 -1
- package/src/contexts/messageOverlayContext/MessageOverlayContext.tsx +8 -1
- package/src/version.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useEffect, useState } from 'react';
|
|
2
|
-
import { Platform } from 'react-native';
|
|
2
|
+
import { Image, Platform } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import Dayjs from 'dayjs';
|
|
5
5
|
|
|
@@ -37,100 +37,101 @@ init();
|
|
|
37
37
|
|
|
38
38
|
export type ChatProps<
|
|
39
39
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
40
|
-
> = Pick<ChatContextValue<StreamChatGenerics>, 'client'> &
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
40
|
+
> = Pick<ChatContextValue<StreamChatGenerics>, 'client'> &
|
|
41
|
+
Partial<Pick<ChatContextValue<StreamChatGenerics>, 'ImageComponent'>> & {
|
|
42
|
+
/**
|
|
43
|
+
* When false, ws connection won't be disconnection upon backgrounding the app.
|
|
44
|
+
* To receive push notifications, its necessary that user doesn't have active
|
|
45
|
+
* websocket connection. So by default, we disconnect websocket connection when
|
|
46
|
+
* app goes to background, and reconnect when app comes to foreground.
|
|
47
|
+
*/
|
|
48
|
+
closeConnectionOnBackground?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Enables offline storage and loading for chat data.
|
|
51
|
+
*/
|
|
52
|
+
enableOfflineSupport?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Instance of Streami18n class should be provided to Chat component to enable internationalization.
|
|
55
|
+
*
|
|
56
|
+
* Stream provides following list of in-built translations:
|
|
57
|
+
* 1. English (en)
|
|
58
|
+
* 2. Dutch (nl)
|
|
59
|
+
* 3. ...
|
|
60
|
+
* 4. ...
|
|
61
|
+
*
|
|
62
|
+
* Simplest way to start using chat components in one of the in-built languages would be following:
|
|
63
|
+
*
|
|
64
|
+
* ```
|
|
65
|
+
* const i18n = new Streami18n('nl');
|
|
66
|
+
* <Chat client={chatClient} i18nInstance={i18n}>
|
|
67
|
+
* ...
|
|
68
|
+
* </Chat>
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* If you would like to override certain keys in in-built translation.
|
|
72
|
+
* UI will be automatically updated in this case.
|
|
73
|
+
*
|
|
74
|
+
* ```
|
|
75
|
+
* const i18n = new Streami18n('nl');
|
|
76
|
+
*
|
|
77
|
+
* i18n.registerTranslation('nl', {
|
|
78
|
+
* 'Nothing yet...': 'Nog Niet ...',
|
|
79
|
+
* '{{ firstUser }} and {{ secondUser }} are typing...': '{{ firstUser }} en {{ secondUser }} zijn aan het typen...',
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* <Chat client={chatClient} i18nInstance={i18n}>
|
|
83
|
+
* ...
|
|
84
|
+
* </Chat>
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* You can use the same function to add whole new language.
|
|
88
|
+
*
|
|
89
|
+
* ```
|
|
90
|
+
* const i18n = new Streami18n('it');
|
|
91
|
+
*
|
|
92
|
+
* i18n.registerTranslation('it', {
|
|
93
|
+
* 'Nothing yet...': 'Non ancora ...',
|
|
94
|
+
* '{{ firstUser }} and {{ secondUser }} are typing...': '{{ firstUser }} a {{ secondUser }} stanno scrivendo...',
|
|
95
|
+
* });
|
|
96
|
+
*
|
|
97
|
+
* // Make sure to call setLanguage to reflect new language in UI.
|
|
98
|
+
* i18n.setLanguage('it');
|
|
99
|
+
* <Chat client={chatClient} i18nInstance={i18n}>
|
|
100
|
+
* ...
|
|
101
|
+
* </Chat>
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
i18nInstance?: Streami18n;
|
|
105
|
+
/**
|
|
106
|
+
* You can pass the theme object to customize the styles of Chat components. You can check the default theme in [theme.ts](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/contexts/themeContext/utils/theme.ts)
|
|
107
|
+
*
|
|
108
|
+
* Please check section about [themes in cookbook](https://github.com/GetStream/stream-chat-react-native/wiki/Cookbook-v3.0#theme) for details.
|
|
109
|
+
*
|
|
110
|
+
* ```
|
|
111
|
+
* import type { DeepPartial, Theme } from 'stream-chat-react-native';
|
|
112
|
+
*
|
|
113
|
+
* const theme: DeepPartial<Theme> = {
|
|
114
|
+
* messageSimple: {
|
|
115
|
+
* file: {
|
|
116
|
+
* container: {
|
|
117
|
+
* backgroundColor: 'red',
|
|
118
|
+
* },
|
|
119
|
+
* icon: {
|
|
120
|
+
* height: 16,
|
|
121
|
+
* width: 16,
|
|
122
|
+
* },
|
|
123
|
+
* },
|
|
124
|
+
* },
|
|
125
|
+
* };
|
|
126
|
+
*
|
|
127
|
+
* <Chat style={theme}>
|
|
128
|
+
* </Chat>
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @overrideType object
|
|
132
|
+
*/
|
|
133
|
+
style?: DeepPartial<Theme>;
|
|
134
|
+
};
|
|
134
135
|
|
|
135
136
|
const ChatWithContext = <
|
|
136
137
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
@@ -143,6 +144,7 @@ const ChatWithContext = <
|
|
|
143
144
|
closeConnectionOnBackground = true,
|
|
144
145
|
enableOfflineSupport = false,
|
|
145
146
|
i18nInstance,
|
|
147
|
+
ImageComponent = Image,
|
|
146
148
|
style,
|
|
147
149
|
} = props;
|
|
148
150
|
|
|
@@ -206,6 +208,7 @@ const ChatWithContext = <
|
|
|
206
208
|
client,
|
|
207
209
|
connectionRecovering,
|
|
208
210
|
enableOfflineSupport,
|
|
211
|
+
ImageComponent,
|
|
209
212
|
isOnline,
|
|
210
213
|
mutedUsers,
|
|
211
214
|
setActiveChannel,
|
|
@@ -11,6 +11,7 @@ export const useCreateChatContext = <
|
|
|
11
11
|
client,
|
|
12
12
|
connectionRecovering,
|
|
13
13
|
enableOfflineSupport,
|
|
14
|
+
ImageComponent,
|
|
14
15
|
isOnline,
|
|
15
16
|
mutedUsers,
|
|
16
17
|
setActiveChannel,
|
|
@@ -31,6 +32,7 @@ export const useCreateChatContext = <
|
|
|
31
32
|
client,
|
|
32
33
|
connectionRecovering,
|
|
33
34
|
enableOfflineSupport,
|
|
35
|
+
ImageComponent,
|
|
34
36
|
isOnline,
|
|
35
37
|
mutedUsers,
|
|
36
38
|
setActiveChannel,
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Image, ImageBackgroundProps, ImageProps, StyleSheet, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* DISCLAIMER: This component has been pretty-much copied from react-native's source code
|
|
7
|
+
* https://github.com/facebook/react-native/blob/main/Libraries/Image/ImageBackground.js
|
|
8
|
+
* Few modifications have been done such as converting to functional component, removing ref related logic (since its not required).
|
|
9
|
+
* Also support for prop `ImageComponent` has been introduced to allow rendering custom
|
|
10
|
+
* component instead of `Image`.
|
|
11
|
+
*
|
|
12
|
+
*
|
|
13
|
+
* Very simple drop-in replacement for <Image> which supports nesting views.
|
|
14
|
+
*
|
|
15
|
+
* ```ReactNativeWebPlayer
|
|
16
|
+
* import React, { Component } from 'react';
|
|
17
|
+
* import { AppRegistry, View, ImageBackground, Text } from 'react-native';
|
|
18
|
+
*
|
|
19
|
+
* class DisplayAnImageBackground extends Component {
|
|
20
|
+
* render() {
|
|
21
|
+
* return (
|
|
22
|
+
* <ImageBackground
|
|
23
|
+
* style={{width: 50, height: 50}}
|
|
24
|
+
* source={{uri: 'https://reactnative.dev/img/opengraph.png'}}
|
|
25
|
+
* >
|
|
26
|
+
* <Text>React</Text>
|
|
27
|
+
* </ImageBackground>
|
|
28
|
+
* );
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
export const ImageBackground: React.ComponentType<
|
|
35
|
+
ImageBackgroundProps & {
|
|
36
|
+
ImageComponent?: React.ComponentType<ImageProps>;
|
|
37
|
+
}
|
|
38
|
+
> = (props) => {
|
|
39
|
+
const {
|
|
40
|
+
children,
|
|
41
|
+
ImageComponent = Image,
|
|
42
|
+
imageStyle,
|
|
43
|
+
importantForAccessibility,
|
|
44
|
+
style,
|
|
45
|
+
...rest
|
|
46
|
+
} = props;
|
|
47
|
+
|
|
48
|
+
const flattenedStyle = StyleSheet.flatten(style);
|
|
49
|
+
return (
|
|
50
|
+
<View
|
|
51
|
+
accessibilityIgnoresInvertColors={true}
|
|
52
|
+
importantForAccessibility={importantForAccessibility}
|
|
53
|
+
style={style}
|
|
54
|
+
>
|
|
55
|
+
<ImageComponent
|
|
56
|
+
{...rest}
|
|
57
|
+
importantForAccessibility={importantForAccessibility}
|
|
58
|
+
style={[
|
|
59
|
+
StyleSheet.absoluteFill,
|
|
60
|
+
{
|
|
61
|
+
// Temporary Workaround:
|
|
62
|
+
// Current (imperfect yet) implementation of <Image> overwrites width and height styles
|
|
63
|
+
// (which is not quite correct), and these styles conflict with explicitly set styles
|
|
64
|
+
// of <ImageBackground> and with our internal layout model here.
|
|
65
|
+
// So, we have to proxy/reapply these styles explicitly for actual <Image> component.
|
|
66
|
+
// This workaround should be removed after implementing proper support of
|
|
67
|
+
// intrinsic content size of the <Image>.
|
|
68
|
+
height: flattenedStyle?.height,
|
|
69
|
+
width: flattenedStyle?.width,
|
|
70
|
+
},
|
|
71
|
+
imageStyle,
|
|
72
|
+
]}
|
|
73
|
+
/>
|
|
74
|
+
{children}
|
|
75
|
+
</View>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
@@ -118,7 +118,6 @@ export type MessagePropsWithContext<
|
|
|
118
118
|
ChannelContextValue<StreamChatGenerics>,
|
|
119
119
|
'channel' | 'disabled' | 'enforceUniqueReaction' | 'members'
|
|
120
120
|
> &
|
|
121
|
-
Pick<ChatContextValue<StreamChatGenerics>, 'client' | 'mutedUsers'> &
|
|
122
121
|
Pick<KeyboardContextValue, 'dismissKeyboard'> &
|
|
123
122
|
Partial<Omit<MessageContextValue<StreamChatGenerics>, 'groupStyles' | 'message'>> &
|
|
124
123
|
Pick<MessageContextValue<StreamChatGenerics>, 'groupStyles' | 'message'> &
|
|
@@ -157,6 +156,7 @@ export type MessagePropsWithContext<
|
|
|
157
156
|
Pick<OverlayContextValue, 'setOverlay'> &
|
|
158
157
|
Pick<ThreadContextValue<StreamChatGenerics>, 'openThread'> &
|
|
159
158
|
Pick<TranslationContextValue, 't'> & {
|
|
159
|
+
chatContext: ChatContextValue<StreamChatGenerics>;
|
|
160
160
|
messagesContext: MessagesContextValue<StreamChatGenerics>;
|
|
161
161
|
/**
|
|
162
162
|
* Whether or not users are able to long press messages.
|
|
@@ -218,7 +218,6 @@ const MessageWithContext = <
|
|
|
218
218
|
|
|
219
219
|
const {
|
|
220
220
|
channel,
|
|
221
|
-
client,
|
|
222
221
|
disabled,
|
|
223
222
|
dismissKeyboard,
|
|
224
223
|
dismissKeyboardOnMessageTouch,
|
|
@@ -238,6 +237,7 @@ const MessageWithContext = <
|
|
|
238
237
|
handleReaction: handleReactionProp,
|
|
239
238
|
handleRetry,
|
|
240
239
|
handleThreadReply,
|
|
240
|
+
chatContext,
|
|
241
241
|
lastReceivedId,
|
|
242
242
|
members,
|
|
243
243
|
message,
|
|
@@ -272,7 +272,7 @@ const MessageWithContext = <
|
|
|
272
272
|
threadList = false,
|
|
273
273
|
updateMessage,
|
|
274
274
|
} = props;
|
|
275
|
-
|
|
275
|
+
const { client } = chatContext;
|
|
276
276
|
const {
|
|
277
277
|
theme: {
|
|
278
278
|
colors: { bg_gradient_start, targetedMessageBackground },
|
|
@@ -547,6 +547,7 @@ const MessageWithContext = <
|
|
|
547
547
|
|
|
548
548
|
setData({
|
|
549
549
|
alignment,
|
|
550
|
+
chatContext,
|
|
550
551
|
clientId: client.userID,
|
|
551
552
|
files: attachments.files,
|
|
552
553
|
groupStyles,
|
|
@@ -719,23 +720,23 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
719
720
|
nextProps: MessagePropsWithContext<StreamChatGenerics>,
|
|
720
721
|
) => {
|
|
721
722
|
const {
|
|
723
|
+
chatContext: { mutedUsers: prevMutedUsers },
|
|
722
724
|
goToMessage: prevGoToMessage,
|
|
723
725
|
isAttachmentEqual,
|
|
724
726
|
isTargetedMessage: prevIsTargetedMessage,
|
|
725
727
|
lastReceivedId: prevLastReceivedId,
|
|
726
728
|
members: prevMembers,
|
|
727
729
|
message: prevMessage,
|
|
728
|
-
mutedUsers: prevMutedUsers,
|
|
729
730
|
showUnreadUnderlay: prevShowUnreadUnderlay,
|
|
730
731
|
t: prevT,
|
|
731
732
|
} = prevProps;
|
|
732
733
|
const {
|
|
734
|
+
chatContext: { mutedUsers: nextMutedUsers },
|
|
733
735
|
goToMessage: nextGoToMessage,
|
|
734
736
|
isTargetedMessage: nextIsTargetedMessage,
|
|
735
737
|
lastReceivedId: nextLastReceivedId,
|
|
736
738
|
members: nextMembers,
|
|
737
739
|
message: nextMessage,
|
|
738
|
-
mutedUsers: nextMutedUsers,
|
|
739
740
|
showUnreadUnderlay: nextShowUnreadUnderlay,
|
|
740
741
|
t: nextT,
|
|
741
742
|
} = nextProps;
|
|
@@ -857,7 +858,7 @@ export const Message = <
|
|
|
857
858
|
) => {
|
|
858
859
|
const { channel, disabled, enforceUniqueReaction, members } =
|
|
859
860
|
useChannelContext<StreamChatGenerics>();
|
|
860
|
-
const
|
|
861
|
+
const chatContext = useChatContext<StreamChatGenerics>();
|
|
861
862
|
const { dismissKeyboard } = useKeyboardContext();
|
|
862
863
|
const { setData } = useMessageOverlayContext<StreamChatGenerics>();
|
|
863
864
|
const messagesContext = useMessagesContext<StreamChatGenerics>();
|
|
@@ -870,13 +871,12 @@ export const Message = <
|
|
|
870
871
|
{...messagesContext}
|
|
871
872
|
{...{
|
|
872
873
|
channel,
|
|
873
|
-
|
|
874
|
+
chatContext,
|
|
874
875
|
disabled,
|
|
875
876
|
dismissKeyboard,
|
|
876
877
|
enforceUniqueReaction,
|
|
877
878
|
members,
|
|
878
879
|
messagesContext,
|
|
879
|
-
mutedUsers,
|
|
880
880
|
openThread,
|
|
881
881
|
setData,
|
|
882
882
|
setOverlay,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
|
|
4
|
+
import { ChatContextValue, useChatContext } from '../../../contexts/chatContext/ChatContext';
|
|
4
5
|
import {
|
|
5
6
|
MessageContextValue,
|
|
6
7
|
useMessageContext,
|
|
@@ -16,6 +17,7 @@ export type MessageAvatarPropsWithContext<
|
|
|
16
17
|
MessageContextValue<StreamChatGenerics>,
|
|
17
18
|
'alignment' | 'lastGroupMessage' | 'message' | 'showAvatar'
|
|
18
19
|
> &
|
|
20
|
+
Pick<ChatContextValue<StreamChatGenerics>, 'ImageComponent'> &
|
|
19
21
|
Partial<Pick<AvatarProps, 'size'>>;
|
|
20
22
|
|
|
21
23
|
const MessageAvatarWithContext = <
|
|
@@ -23,7 +25,7 @@ const MessageAvatarWithContext = <
|
|
|
23
25
|
>(
|
|
24
26
|
props: MessageAvatarPropsWithContext<StreamChatGenerics>,
|
|
25
27
|
) => {
|
|
26
|
-
const { alignment, lastGroupMessage, message, showAvatar, size } = props;
|
|
28
|
+
const { alignment, ImageComponent, lastGroupMessage, message, showAvatar, size } = props;
|
|
27
29
|
const {
|
|
28
30
|
theme: {
|
|
29
31
|
avatar: { BASE_AVATAR_SIZE },
|
|
@@ -43,6 +45,7 @@ const MessageAvatarWithContext = <
|
|
|
43
45
|
{visible ? (
|
|
44
46
|
<Avatar
|
|
45
47
|
image={message.user?.image}
|
|
48
|
+
ImageComponent={ImageComponent}
|
|
46
49
|
name={message.user?.name || message.user?.id}
|
|
47
50
|
size={size || BASE_AVATAR_SIZE}
|
|
48
51
|
/>
|
|
@@ -88,11 +91,12 @@ export const MessageAvatar = <
|
|
|
88
91
|
) => {
|
|
89
92
|
const { alignment, lastGroupMessage, message, showAvatar } =
|
|
90
93
|
useMessageContext<StreamChatGenerics>();
|
|
91
|
-
|
|
94
|
+
const { ImageComponent } = useChatContext<StreamChatGenerics>();
|
|
92
95
|
return (
|
|
93
96
|
<MemoizedMessageAvatar
|
|
94
97
|
{...{
|
|
95
98
|
alignment,
|
|
99
|
+
ImageComponent,
|
|
96
100
|
lastGroupMessage,
|
|
97
101
|
message,
|
|
98
102
|
showAvatar,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { StyleSheet, View } from 'react-native';
|
|
3
3
|
|
|
4
|
+
import { ChatContextValue, useChatContext } from '../../../contexts/chatContext/ChatContext';
|
|
4
5
|
import type { MessageContextValue } from '../../../contexts/messageContext/MessageContext';
|
|
5
6
|
import { useTheme } from '../../../contexts/themeContext/ThemeContext';
|
|
6
7
|
|
|
@@ -23,12 +24,12 @@ export type MessageRepliesAvatarsProps<
|
|
|
23
24
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
24
25
|
> = Pick<MessageContextValue<StreamChatGenerics>, 'alignment' | 'message'>;
|
|
25
26
|
|
|
26
|
-
export const
|
|
27
|
+
export const MessageRepliesAvatarsWithContext = <
|
|
27
28
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
28
29
|
>(
|
|
29
|
-
props: MessageRepliesAvatarsProps<StreamChatGenerics>,
|
|
30
|
+
props: MessageRepliesAvatarsProps<StreamChatGenerics> & Pick<ChatContextValue, 'ImageComponent'>,
|
|
30
31
|
) => {
|
|
31
|
-
const { alignment, message } = props;
|
|
32
|
+
const { alignment, ImageComponent, message } = props;
|
|
32
33
|
|
|
33
34
|
const {
|
|
34
35
|
theme: {
|
|
@@ -77,6 +78,7 @@ export const MessageRepliesAvatars = <
|
|
|
77
78
|
avatar,
|
|
78
79
|
]}
|
|
79
80
|
image={user.image}
|
|
81
|
+
ImageComponent={ImageComponent}
|
|
80
82
|
name={user.name}
|
|
81
83
|
size={avatarSize ? avatarSize : i === 1 ? 18 : 16}
|
|
82
84
|
/>
|
|
@@ -85,3 +87,13 @@ export const MessageRepliesAvatars = <
|
|
|
85
87
|
</View>
|
|
86
88
|
);
|
|
87
89
|
};
|
|
90
|
+
|
|
91
|
+
export const MessageRepliesAvatars = <
|
|
92
|
+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
93
|
+
>(
|
|
94
|
+
props: MessageRepliesAvatarsProps<StreamChatGenerics>,
|
|
95
|
+
) => {
|
|
96
|
+
const { ImageComponent } = useChatContext();
|
|
97
|
+
|
|
98
|
+
return <MessageRepliesAvatarsWithContext {...props} ImageComponent={ImageComponent} />;
|
|
99
|
+
};
|