Skip to content

Commit 927a65a

Browse files
committed
chore: remove SCG from sample app
1 parent cad462e commit 927a65a

39 files changed

+206
-216
lines changed

examples/SampleApp/App.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ if (__DEV__) {
4747

4848
import type {
4949
StackNavigatorParamList,
50-
StreamChatGenerics,
5150
UserSelectorParamList,
5251
} from './src/types';
5352
import { GestureHandlerRootView } from 'react-native-gesture-handler';
@@ -171,21 +170,23 @@ const DrawerNavigator: React.FC = () => (
171170
</Drawer.Navigator>
172171
);
173172

173+
const isMessageAIGenerated = (message: MessageType) => !!message.ai_generated;
174+
174175
const DrawerNavigatorWrapper: React.FC<{
175-
chatClient: StreamChat<StreamChatGenerics>;
176+
chatClient: StreamChat;
176177
}> = ({ chatClient }) => {
177178
const { bottom } = useSafeAreaInsets();
178179
const streamChatTheme = useStreamChatTheme();
179180

180181
return (
181182
<GestureHandlerRootView style={{ flex: 1 }}>
182-
<OverlayProvider<StreamChatGenerics> bottomInset={bottom} value={{ style: streamChatTheme }}>
183-
<Chat<StreamChatGenerics>
183+
<OverlayProvider bottomInset={bottom} value={{ style: streamChatTheme }}>
184+
<Chat
184185
client={chatClient}
185186
enableOfflineSupport
186187
// @ts-expect-error - the `ImageComponent` prop is generic, meaning we can expect an error
187188
ImageComponent={FastImage}
188-
isMessageAIGenerated={(message: MessageType) => !!message.ai_generated}
189+
isMessageAIGenerated={isMessageAIGenerated}
189190
>
190191
<AppOverlayProvider>
191192
<UserSearchProvider>

examples/SampleApp/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "sampleapp",
33
"version": "2.5.0",
44
"private": true,
5+
"type": "module",
56
"repository": {
67
"type": "git",
78
"url": "https://github.com/GetStream/stream-chat-react-native.git"

examples/SampleApp/src/ChatUsers.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { UserResponse } from 'stream-chat';
2-
import { StreamChatGenerics } from './types';
32

43
export const USER_TOKENS: Record<string, string> = {
54
e2etest1:
@@ -27,7 +26,7 @@ export const USER_TOKENS: Record<string, string> = {
2726
rodolphe:
2827
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoicm9kb2xwaGUifQ.tLl-I8ADBhTKB-x5FB9jK4-am0dELLXgydM6VN9rTL8',
2928
};
30-
export const USERS: Record<string, UserResponse<StreamChatGenerics>> = {
29+
export const USERS: Record<string, UserResponse> = {
3130
neil: {
3231
id: 'neil',
3332
image: 'https://ca.slack-edge.com/T02RM6X6B-U01173D1D5J-0dead6eea6ea-512',

examples/SampleApp/src/components/AddMemberBottomSheet.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import { usePaginatedUsers } from '../hooks/usePaginatedUsers';
2121

2222
import type { UserResponse } from 'stream-chat';
2323

24-
import { StreamChatGenerics } from '../types';
25-
2624
const styles = StyleSheet.create({
2725
container: {
2826
height: 300,
@@ -94,7 +92,7 @@ export const AddMemberBottomSheet: React.FC = () => {
9492
return null;
9593
}
9694

97-
const addMember = async (user: UserResponse<StreamChatGenerics>) => {
95+
const addMember = async (user: UserResponse) => {
9896
setAddMemberQueryInProgress(true);
9997

10098
try {

examples/SampleApp/src/components/ChannelInfoOverlay.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
useTheme,
3030
useViewport,
3131
} from 'stream-chat-react-native';
32+
import { ChannelMemberResponse } from 'stream-chat';
3233

3334
import { useAppOverlayContext } from '../context/AppOverlayContext';
3435
import { useBottomSheetOverlayContext } from '../context/BottomSheetOverlayContext';
@@ -224,9 +225,9 @@ export const ChannelInfoOverlay = (props: ChannelInfoOverlayProps) => {
224225
: 0;
225226
const channelName = channel
226227
? channel.data?.name ||
227-
Object.values(channel.state.members)
228+
Object.values<ChannelMemberResponse>(channel.state.members)
228229
.slice(0)
229-
.reduce((returnString, currentMember, index, originalArray) => {
230+
.reduce<string>((returnString, currentMember, index, originalArray) => {
230231
const returnStringLength = returnString.length;
231232
const currentMemberName =
232233
currentMember.user?.name || currentMember.user?.id || 'Unknown User';
@@ -246,7 +247,7 @@ export const ChannelInfoOverlay = (props: ChannelInfoOverlayProps) => {
246247
}, '')
247248
: '';
248249
const otherMembers = channel
249-
? Object.values(channel.state.members).filter((member) => member.user?.id !== clientId)
250+
? Object.values<ChannelMemberResponse>(channel.state.members).filter((member) => member.user?.id !== clientId)
250251
: [];
251252

252253
return (
@@ -292,14 +293,14 @@ export const ChannelInfoOverlay = (props: ChannelInfoOverlayProps) => {
292293
? 'Online'
293294
: `Last Seen ${dayjs(otherMembers[0].user?.last_active).fromNow()}`
294295
: `${Object.keys(channel.state.members).length} Members, ${
295-
Object.values(channel.state.members).filter(
296+
Object.values<ChannelMemberResponse>(channel.state.members).filter(
296297
(member) => !!member.user?.online,
297298
).length
298299
} Online`}
299300
</Text>
300301
<FlatList
301302
contentContainerStyle={styles.flatListContent}
302-
data={Object.values(channel.state.members)
303+
data={Object.values<ChannelMemberResponse>(channel.state.members)
303304
.map((member) => member.user)
304305
.sort((a, b) =>
305306
!!a?.online && !b?.online

examples/SampleApp/src/components/ChannelPreview.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { useChannelInfoOverlayContext } from '../context/ChannelInfoOverlayConte
2222

2323
import type { StackNavigationProp } from '@react-navigation/stack';
2424

25-
import type { StackNavigatorParamList, StreamChatGenerics } from '../types';
25+
import type { StackNavigatorParamList } from '../types';
2626
import { ChannelState } from 'stream-chat';
2727

2828
const styles = StyleSheet.create({
@@ -71,7 +71,7 @@ const CustomChannelPreviewStatus = (
7171
);
7272
};
7373

74-
export const ChannelPreview: React.FC<ChannelPreviewMessengerProps<StreamChatGenerics>> = (
74+
export const ChannelPreview: React.FC<ChannelPreviewMessengerProps> = (
7575
props,
7676
) => {
7777
const { channel } = props;
@@ -82,7 +82,7 @@ export const ChannelPreview: React.FC<ChannelPreviewMessengerProps<StreamChatGen
8282

8383
const { data, setData } = useChannelInfoOverlayContext();
8484

85-
const { client } = useChatContext<StreamChatGenerics>();
85+
const { client } = useChatContext();
8686

8787
const navigation = useNavigation<ChannelListScreenNavigationProp>();
8888

examples/SampleApp/src/components/MessageSearch/MessageSearchList.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { DEFAULT_PAGINATION_LIMIT } from '../../utils/constants';
88

99
import type { MessageResponse } from 'stream-chat';
1010

11-
import type { StackNavigatorParamList, StreamChatGenerics } from '../../types';
11+
import type { StackNavigatorParamList } from '../../types';
1212

1313
dayjs.extend(calendar);
1414

@@ -52,13 +52,13 @@ export type MessageSearchListProps = {
5252
EmptySearchIndicator: React.ComponentType;
5353
loading: boolean;
5454
loadMore: () => void;
55-
messages: MessageResponse<StreamChatGenerics>[] | undefined;
55+
messages: MessageResponse[] | undefined;
5656
refreshing?: boolean;
5757
refreshList?: () => void;
5858
showResultCount?: boolean;
5959
};
6060
export const MessageSearchList: React.FC<MessageSearchListProps> = React.forwardRef(
61-
(props, scrollRef: React.Ref<FlatList<MessageResponse<StreamChatGenerics>> | null>) => {
61+
(props, scrollRef: React.Ref<FlatList<MessageResponse> | null>) => {
6262
const {
6363
EmptySearchIndicator,
6464
loading,

examples/SampleApp/src/components/NewDirectMessagingSendButton.tsx

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { TouchableOpacity } from 'react-native-gesture-handler';
44
import { useNavigation } from '@react-navigation/core';
55

66
import {
7-
DefaultStreamChatGenerics,
87
MessageInputContextValue,
98
Search,
109
SendRight,
@@ -16,20 +15,15 @@ import {
1615

1716
import { NewDirectMessagingScreenNavigationProp } from '../screens/NewDirectMessagingScreen';
1817

19-
import { StreamChatGenerics as LocalStreamChatGenerics } from '../types';
2018
import { useUserSearchContext } from '../context/UserSearchContext';
2119
import { useAppContext } from '../context/AppContext';
2220

23-
type NewDirectMessagingSendButtonPropsWithContext<
24-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
25-
> = Pick<MessageInputContextValue<StreamChatGenerics>, 'giphyActive' | 'sendMessage'> & {
21+
type NewDirectMessagingSendButtonPropsWithContext = Pick<MessageInputContextValue, 'giphyActive' | 'sendMessage'> & {
2622
/** Disables the button */ disabled: boolean;
2723
};
2824

29-
const SendButtonWithContext = <
30-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
31-
>(
32-
props: NewDirectMessagingSendButtonPropsWithContext<StreamChatGenerics>,
25+
const SendButtonWithContext = (
26+
props: NewDirectMessagingSendButtonPropsWithContext,
3327
) => {
3428
const { disabled = false, giphyActive, sendMessage } = props;
3529
const {
@@ -53,9 +47,9 @@ const SendButtonWithContext = <
5347
);
5448
};
5549

56-
const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(
57-
prevProps: NewDirectMessagingSendButtonPropsWithContext<StreamChatGenerics>,
58-
nextProps: NewDirectMessagingSendButtonPropsWithContext<StreamChatGenerics>,
50+
const areEqual = (
51+
prevProps: NewDirectMessagingSendButtonPropsWithContext,
52+
nextProps: NewDirectMessagingSendButtonPropsWithContext,
5953
) => {
6054
const {
6155
disabled: prevDisabled,
@@ -91,20 +85,18 @@ const MemoizedNewDirectMessagingSendButton = React.memo(
9185
areEqual,
9286
) as typeof SendButtonWithContext;
9387

94-
export type SendButtonProps<
95-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
96-
> = Partial<NewDirectMessagingSendButtonPropsWithContext<StreamChatGenerics>>;
88+
export type SendButtonProps = Partial<NewDirectMessagingSendButtonPropsWithContext>;
9789

9890
/**
9991
* UI Component for send button in MessageInput component.
10092
*/
101-
export const NewDirectMessagingSendButton = (props: SendButtonProps<LocalStreamChatGenerics>) => {
93+
export const NewDirectMessagingSendButton = (props: SendButtonProps) => {
10294
const { chatClient } = useAppContext();
10395
const navigation = useNavigation<NewDirectMessagingScreenNavigationProp>();
104-
const { channel } = useChannelContext<LocalStreamChatGenerics>();
96+
const { channel } = useChannelContext();
10597
const { selectedUserIds, reset } = useUserSearchContext();
10698

107-
const { giphyActive, text } = useMessageInputContext<LocalStreamChatGenerics>();
99+
const { giphyActive, text } = useMessageInputContext();
108100

109101
const sendMessage = async () => {
110102
if (!channel) {
@@ -133,7 +125,7 @@ export const NewDirectMessagingSendButton = (props: SendButtonProps<LocalStreamC
133125
};
134126

135127
return (
136-
<MemoizedNewDirectMessagingSendButton<LocalStreamChatGenerics>
128+
<MemoizedNewDirectMessagingSendButton
137129
{...{ giphyActive, sendMessage }}
138130
{...props}
139131
{...{ disabled: props.disabled || false }}

examples/SampleApp/src/components/UnreadCountBadge.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const selector = (nextValue: ThreadManagerState) =>
2525

2626
export const ThreadsUnreadCountBadge: React.FC = () => {
2727
const { chatClient } = useAppContext();
28-
const { unreadCount } = useStateStore(chatClient?.threads?.state, selector);
28+
const { unreadCount } = useStateStore(chatClient?.threads?.state, selector) ?? { unreadCount: 0 };
2929

3030
return <UnreadCountBadge unreadCount={unreadCount} />;
3131
};

examples/SampleApp/src/components/UserInfoOverlay.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import { useAppOverlayContext } from '../context/AppOverlayContext';
3535
import { useBottomSheetOverlayContext } from '../context/BottomSheetOverlayContext';
3636
import { useUserInfoOverlayContext } from '../context/UserInfoOverlayContext';
3737

38-
import type { StreamChatGenerics } from '../types';
3938
import { useAppContext } from '../context/AppContext';
4039
import { UserResponse } from 'stream-chat';
4140

@@ -105,7 +104,7 @@ export const UserInfoOverlay = (props: UserInfoOverlayProps) => {
105104
const { overlayOpacity, visible } = props;
106105
const { chatClient } = useAppContext();
107106
const { overlay, setOverlay } = useAppOverlayContext();
108-
const { client } = useChatContext<StreamChatGenerics>();
107+
const { client } = useChatContext();
109108
const { setData } = useBottomSheetOverlayContext();
110109
const { data, reset } = useUserInfoOverlayContext();
111110
const { vh } = useViewport();
@@ -298,7 +297,6 @@ export const UserInfoOverlay = (props: UserInfoOverlayProps) => {
298297

299298
// Check if the channel already exists.
300299
const channels = await client.queryChannels({
301-
distinct: true,
302300
members,
303301
});
304302

@@ -351,7 +349,6 @@ export const UserInfoOverlay = (props: UserInfoOverlayProps) => {
351349

352350
// Check if the channel already exists.
353351
const channels = await client.queryChannels({
354-
distinct: true,
355352
members,
356353
});
357354

0 commit comments

Comments
 (0)