Skip to content

Commit 7eb09c9

Browse files
committed
chore: move prop to Chat component
1 parent 5220352 commit 7eb09c9

File tree

6 files changed

+17
-5
lines changed

6 files changed

+17
-5
lines changed

examples/SampleApp/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { createStackNavigator } from '@react-navigation/stack';
66
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context';
77
import {
88
Chat,
9+
MessageType,
910
OverlayProvider,
1011
QuickSqliteClient,
1112
ThemeProvider,
@@ -182,6 +183,7 @@ const DrawerNavigatorWrapper: React.FC<{
182183
enableOfflineSupport
183184
// @ts-expect-error
184185
ImageComponent={FastImage}
186+
isMessageAIGenerated={(message: MessageType) => message.ai_generated}
185187
>
186188
<AppOverlayProvider>
187189
<UserSearchProvider>

examples/SampleApp/src/screens/ChannelScreen.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
useTheme,
1414
useTypingString,
1515
AITypingIndicatorView,
16-
MessageType,
1716
} from 'stream-chat-react-native';
1817
import { Platform, StyleSheet, View } from 'react-native';
1918
import type { StackNavigationProp } from '@react-navigation/stack';
@@ -159,7 +158,6 @@ export const ChannelScreen: React.FC<ChannelScreenProps> = ({
159158
messageId={messageId}
160159
NetworkDownIndicator={() => null}
161160
thread={selectedThread}
162-
isMessageAIGenerated={(message: MessageType) => message.ai_generated}
163161
>
164162
<ChannelHeader channel={channel} />
165163
<MessageList<StreamChatGenerics>

package/src/components/Channel/Channel.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2563,7 +2563,8 @@ export const Channel = <
25632563
>(
25642564
props: PropsWithChildren<ChannelProps<StreamChatGenerics>>,
25652565
) => {
2566-
const { client, enableOfflineSupport } = useChatContext<StreamChatGenerics>();
2566+
const { client, enableOfflineSupport, isMessageAIGenerated } =
2567+
useChatContext<StreamChatGenerics>();
25672568
const { t } = useTranslationContext();
25682569

25692570
const threadFromProps = props?.thread;
@@ -2609,6 +2610,7 @@ export const Channel = <
26092610
{...props}
26102611
shouldSyncChannel={shouldSyncChannel}
26112612
{...{
2613+
isMessageAIGenerated,
26122614
members,
26132615
messages: props.messages || messages,
26142616
read,

package/src/components/Chat/Chat.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ init();
3636
export type ChatProps<
3737
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
3838
> = Pick<ChatContextValue<StreamChatGenerics>, 'client'> &
39-
Partial<Pick<ChatContextValue<StreamChatGenerics>, 'ImageComponent' | 'resizableCDNHosts'>> & {
39+
Partial<
40+
Pick<
41+
ChatContextValue<StreamChatGenerics>,
42+
'ImageComponent' | 'resizableCDNHosts' | 'isMessageAIGenerated'
43+
>
44+
> & {
4045
/**
4146
* When false, ws connection won't be disconnection upon backgrounding the app.
4247
* To receive push notifications, its necessary that user doesn't have active
@@ -149,6 +154,7 @@ const ChatWithContext = <
149154
enableOfflineSupport = false,
150155
i18nInstance,
151156
ImageComponent = Image,
157+
isMessageAIGenerated,
152158
LoadingIndicator = null,
153159
resizableCDNHosts = ['.stream-io-cdn.com'],
154160
style,
@@ -250,6 +256,7 @@ const ChatWithContext = <
250256
connectionRecovering,
251257
enableOfflineSupport,
252258
ImageComponent,
259+
isMessageAIGenerated,
253260
isOnline,
254261
mutedUsers,
255262
resizableCDNHosts,

package/src/components/Chat/hooks/useCreateChatContext.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const useCreateChatContext = <
1212
connectionRecovering,
1313
enableOfflineSupport,
1414
ImageComponent,
15+
isMessageAIGenerated,
1516
isOnline,
1617
mutedUsers,
1718
resizableCDNHosts,
@@ -33,6 +34,7 @@ export const useCreateChatContext = <
3334
connectionRecovering,
3435
enableOfflineSupport,
3536
ImageComponent,
37+
isMessageAIGenerated,
3638
isOnline,
3739
mutedUsers,
3840
resizableCDNHosts,

package/src/contexts/chatContext/ChatContext.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { ImageProps } from 'react-native';
44
import type { AppSettingsAPIResponse, Channel, Mute, StreamChat } from 'stream-chat';
55

66
import type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';
7+
import { MessageContextValue } from '../messageContext/MessageContext';
78
import { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';
89

910
import { getDisplayName } from '../utils/getDisplayName';
@@ -69,7 +70,7 @@ export type ChatContextValue<
6970
* This option allows you to specify a list of CDNs that offer image resizing.
7071
*/
7172
resizableCDNHosts?: string[];
72-
};
73+
} & Partial<Pick<MessageContextValue<StreamChatGenerics>, 'isMessageAIGenerated'>>;
7374

7475
export const ChatContext = React.createContext(DEFAULT_BASE_CONTEXT_VALUE as ChatContextValue);
7576

0 commit comments

Comments
 (0)