Skip to content

Commit e3d6782

Browse files
committed
fix: typescipt issues and added new generics support for example apps
1 parent 3b45809 commit e3d6782

File tree

51 files changed

+272
-898
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+272
-898
lines changed

examples/SampleApp/App.tsx

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,7 @@ import { UserSelectorScreen } from './src/screens/UserSelectorScreen';
2929

3030
import type { StreamChat } from 'stream-chat';
3131

32-
import type {
33-
LocalAttachmentType,
34-
LocalChannelType,
35-
LocalCommandType,
36-
LocalEventType,
37-
LocalMessageType,
38-
LocalReactionType,
39-
LocalUserType,
40-
StackNavigatorParamList,
41-
UserSelectorParamList,
42-
} from './src/types';
32+
import type { StackNavigatorParamList, StreamChatType, UserSelectorParamList } from './src/types';
4333

4434
LogBox.ignoreAllLogs(true);
4535
LogBox.ignoreLogs(['Non-serializable values were found in the navigation state']);
@@ -97,43 +87,14 @@ const DrawerNavigator: React.FC = () => (
9787
);
9888

9989
const DrawerNavigatorWrapper: React.FC<{
100-
chatClient: StreamChat<
101-
LocalAttachmentType,
102-
LocalChannelType,
103-
LocalCommandType,
104-
LocalEventType,
105-
LocalMessageType,
106-
LocalReactionType,
107-
LocalUserType
108-
>;
90+
chatClient: StreamChat<StreamChatType>;
10991
}> = ({ chatClient }) => {
11092
const { bottom } = useSafeAreaInsets();
11193
const streamChatTheme = useStreamChatTheme();
11294

11395
return (
114-
<OverlayProvider<
115-
LocalAttachmentType,
116-
LocalChannelType,
117-
LocalCommandType,
118-
LocalEventType,
119-
LocalMessageType,
120-
LocalReactionType,
121-
LocalUserType
122-
>
123-
bottomInset={bottom}
124-
value={{ style: streamChatTheme }}
125-
>
126-
<Chat<
127-
LocalAttachmentType,
128-
LocalChannelType,
129-
LocalCommandType,
130-
LocalEventType,
131-
LocalMessageType,
132-
LocalReactionType,
133-
LocalUserType
134-
>
135-
client={chatClient}
136-
>
96+
<OverlayProvider<StreamChatType> bottomInset={bottom} value={{ style: streamChatTheme }}>
97+
<Chat<StreamChatType> client={chatClient}>
13798
<AppOverlayProvider>
13899
<UserSearchProvider>
139100
<DrawerNavigator />

examples/SampleApp/src/ChatUsers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { UserResponse } from 'stream-chat';
2-
import { LocalUserType } from './types';
2+
import { StreamChatType } from './types';
33

44
export const USER_TOKENS: Record<string, string> = {
55
e2etest1:
@@ -21,7 +21,7 @@ export const USER_TOKENS: Record<string, string> = {
2121
vishal:
2222
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoidmlzaGFsIn0.HOlVh-ZyQnjyuL20G-67RTgKufBuAH-I-gbEELFlass',
2323
};
24-
export const USERS: Record<string, UserResponse<LocalUserType>> = {
24+
export const USERS: Record<string, UserResponse<StreamChatType>> = {
2525
neil: {
2626
id: 'neil',
2727
image: 'https://ca.slack-edge.com/T02RM6X6B-U01173D1D5J-0dead6eea6ea-512',

examples/SampleApp/src/components/AddMemberBottomSheet.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { usePaginatedUsers } from '../hooks/usePaginatedUsers';
1515

1616
import type { UserResponse } from 'stream-chat';
1717

18-
import { LocalUserType } from '../types';
18+
import { StreamChatType } from '../types';
1919

2020
const styles = StyleSheet.create({
2121
container: {
@@ -89,7 +89,7 @@ export const AddMemberBottomSheet: React.FC = () => {
8989
return null;
9090
}
9191

92-
const addMember = async (user: UserResponse<LocalUserType>) => {
92+
const addMember = async (user: UserResponse<StreamChatType>) => {
9393
setAddMemberQueryInProgress(true);
9494

9595
try {

examples/SampleApp/src/components/ChannelPreview.tsx

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

1919
import type { StackNavigationProp } from '@react-navigation/stack';
2020

21-
import type {
22-
LocalAttachmentType,
23-
LocalChannelType,
24-
LocalCommandType,
25-
LocalEventType,
26-
LocalMessageType,
27-
LocalReactionType,
28-
LocalUserType,
29-
StackNavigatorParamList,
30-
} from '../types';
21+
import type { StackNavigatorParamList, StreamChatType } from '../types';
3122

3223
const styles = StyleSheet.create({
3324
leftSwipeableButton: {
@@ -51,17 +42,7 @@ type ChannelListScreenNavigationProp = StackNavigationProp<
5142
'ChannelListScreen'
5243
>;
5344

54-
export const ChannelPreview: React.FC<
55-
ChannelPreviewMessengerProps<
56-
LocalAttachmentType,
57-
LocalChannelType,
58-
LocalCommandType,
59-
LocalEventType,
60-
LocalMessageType,
61-
LocalReactionType,
62-
LocalUserType
63-
>
64-
> = (props) => {
45+
export const ChannelPreview: React.FC<ChannelPreviewMessengerProps<StreamChatType>> = (props) => {
6546
const { channel } = props;
6647

6748
const { setOverlay } = useAppOverlayContext();
@@ -70,15 +51,7 @@ export const ChannelPreview: React.FC<
7051

7152
const { data, setData } = useChannelInfoOverlayContext();
7253

73-
const { client } = useChatContext<
74-
LocalAttachmentType,
75-
LocalChannelType,
76-
LocalCommandType,
77-
LocalEventType,
78-
LocalMessageType,
79-
LocalReactionType,
80-
LocalUserType
81-
>();
54+
const { client } = useChatContext<StreamChatType>();
8255

8356
const navigation = useNavigation<ChannelListScreenNavigationProp>();
8457

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

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,7 @@ import { MESSAGE_SEARCH_LIMIT } from '../../hooks/usePaginatedSearchedMessages';
88

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

11-
import type {
12-
LocalAttachmentType,
13-
LocalChannelType,
14-
LocalCommandType,
15-
LocalMessageType,
16-
LocalReactionType,
17-
LocalUserType,
18-
} from '../../types';
11+
import type { StreamChatType } from '../../types';
1912

2013
const styles = StyleSheet.create({
2114
contentContainer: { flexGrow: 1 },
@@ -59,34 +52,13 @@ export type MessageSearchListProps = {
5952
EmptySearchIndicator: React.ComponentType;
6053
loading: boolean;
6154
loadMore: () => void;
62-
messages:
63-
| MessageResponse<
64-
LocalAttachmentType,
65-
LocalChannelType,
66-
LocalCommandType,
67-
LocalMessageType,
68-
LocalReactionType,
69-
LocalUserType
70-
>[]
71-
| undefined;
55+
messages: MessageResponse<StreamChatType>[] | undefined;
7256
refreshing?: boolean;
7357
refreshList?: () => void;
7458
showResultCount?: boolean;
7559
};
7660
export const MessageSearchList: React.FC<MessageSearchListProps> = React.forwardRef(
77-
(
78-
props,
79-
scrollRef: React.Ref<FlatList<
80-
MessageResponse<
81-
LocalAttachmentType,
82-
LocalChannelType,
83-
LocalCommandType,
84-
LocalMessageType,
85-
LocalReactionType,
86-
LocalUserType
87-
>
88-
> | null>,
89-
) => {
61+
(props, scrollRef: React.Ref<FlatList<MessageResponse<StreamChatType>> | null>) => {
9062
const {
9163
EmptySearchIndicator,
9264
loading,

examples/SampleApp/src/components/NewDirectMessagingSendButton.tsx

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,7 @@ import {
2323

2424
import { NewDirectMessagingScreenNavigationProp } from '../screens/NewDirectMessagingScreen';
2525

26-
import {
27-
LocalAttachmentType,
28-
LocalChannelType,
29-
LocalCommandType,
30-
LocalEventType,
31-
LocalMessageType,
32-
LocalReactionType,
33-
LocalUserType,
34-
} from '../types';
26+
import { StreamChatType } from '../types';
3527

3628
type NewDirectMessagingSendButtonPropsWithContext<
3729
At extends UnknownType = DefaultAttachmentType,
@@ -131,37 +123,11 @@ export type SendButtonProps<
131123
/**
132124
* UI Component for send button in MessageInput component.
133125
*/
134-
export const NewDirectMessagingSendButton = (
135-
props: SendButtonProps<
136-
LocalAttachmentType,
137-
LocalChannelType,
138-
LocalCommandType,
139-
LocalEventType,
140-
LocalMessageType,
141-
LocalReactionType,
142-
LocalUserType
143-
>,
144-
) => {
126+
export const NewDirectMessagingSendButton = (props: SendButtonProps<StreamChatType>) => {
145127
const navigation = useNavigation<NewDirectMessagingScreenNavigationProp>();
146-
const { channel } = useChannelContext<
147-
LocalAttachmentType,
148-
LocalChannelType,
149-
LocalCommandType,
150-
LocalEventType,
151-
LocalMessageType,
152-
LocalReactionType,
153-
LocalUserType
154-
>();
155-
156-
const { giphyActive, text } = useMessageInputContext<
157-
LocalAttachmentType,
158-
LocalChannelType,
159-
LocalCommandType,
160-
LocalEventType,
161-
LocalMessageType,
162-
LocalReactionType,
163-
LocalUserType
164-
>();
128+
const { channel } = useChannelContext<StreamChatType>();
129+
130+
const { giphyActive, text } = useMessageInputContext<StreamChatType>();
165131

166132
const sendMessage = async () => {
167133
if (!channel) return;
@@ -178,15 +144,7 @@ export const NewDirectMessagingSendButton = (
178144
};
179145

180146
return (
181-
<MemoizedNewDirectMessagingSendButton<
182-
LocalAttachmentType,
183-
LocalChannelType,
184-
LocalCommandType,
185-
LocalEventType,
186-
LocalMessageType,
187-
LocalReactionType,
188-
LocalUserType
189-
>
147+
<MemoizedNewDirectMessagingSendButton<StreamChatType>
190148
{...{ giphyActive, sendMessage }}
191149
{...props}
192150
{...{ disabled: props.disabled || false }}

examples/SampleApp/src/components/UserSearch/SelectedUserTag.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useTheme } from 'stream-chat-react-native';
44

55
import type { UserResponse } from 'stream-chat';
66

7-
import type { LocalUserType } from '../../types';
7+
import type { StreamChatType } from '../../types';
88

99
const styles = StyleSheet.create({
1010
tagContainer: {
@@ -29,7 +29,7 @@ const styles = StyleSheet.create({
2929
type SelectedUserTagProps = {
3030
index: number;
3131
onPress: () => void;
32-
tag: UserResponse<LocalUserType>;
32+
tag: UserResponse<StreamChatType>;
3333
disabled?: boolean;
3434
};
3535

examples/SampleApp/src/components/UserSearch/UserGridItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Avatar, Close, useTheme } from 'stream-chat-react-native';
55

66
import type { UserResponse } from 'stream-chat';
77

8-
import type { LocalUserType } from '../../types';
8+
import type { StreamChatType } from '../../types';
99

1010
const presenceIndicator = { cx: 7, cy: 7, r: 5 };
1111

@@ -40,7 +40,7 @@ const styles = StyleSheet.create({
4040

4141
export type UserGridItemProps = {
4242
onPress: () => void;
43-
user: UserResponse<LocalUserType>;
43+
user: UserResponse<StreamChatType>;
4444
removeButton?: boolean;
4545
};
4646

examples/SampleApp/src/components/UserSearch/UserSearchResults.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { useUserSearchContext } from '../../context/UserSearchContext';
1515

1616
import type { UserResponse } from 'stream-chat';
1717

18-
import type { LocalUserType } from '../../types';
18+
import type { StreamChatType } from '../../types';
1919
import { Search } from '../../icons/Search';
2020

2121
const styles = StyleSheet.create({
@@ -62,9 +62,9 @@ const styles = StyleSheet.create({
6262
type UserSearchResultsProps = {
6363
groupedAlphabetically?: boolean;
6464
removeOnPressOnly?: boolean;
65-
results?: UserResponse<LocalUserType>[];
65+
results?: UserResponse<StreamChatType>[];
6666
showOnlineStatus?: boolean;
67-
toggleSelectedUser?: (user: UserResponse<LocalUserType>) => void;
67+
toggleSelectedUser?: (user: UserResponse<StreamChatType>) => void;
6868
};
6969

7070
export const UserSearchResults: React.FC<UserSearchResultsProps> = ({
@@ -84,7 +84,7 @@ export const UserSearchResults: React.FC<UserSearchResultsProps> = ({
8484
} = useUserSearchContext();
8585
const [sections, setSections] = useState<
8686
Array<{
87-
data: UserResponse<LocalUserType>[];
87+
data: UserResponse<StreamChatType>[];
8888
title: string;
8989
}>
9090
>([]);
@@ -109,7 +109,7 @@ export const UserSearchResults: React.FC<UserSearchResultsProps> = ({
109109
useEffect(() => {
110110
const newSections: {
111111
[key: string]: {
112-
data: UserResponse<LocalUserType>[];
112+
data: UserResponse<StreamChatType>[];
113113
title: string;
114114
};
115115
} = {};

examples/SampleApp/src/components/UserSearch/UserSearchResultsGrid.tsx

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

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

11-
import type { LocalUserType } from '../../types';
11+
import type { StreamChatType } from '../../types';
1212

1313
const totalUserSpace = vw(100) - 56; // 36 = outside margin 8 * 2 + inner padding 20 * 2;
1414

@@ -31,8 +31,8 @@ const styles = StyleSheet.create({
3131
});
3232

3333
type UserSearchResultsGridProps = {
34-
onPress: (user: UserResponse<LocalUserType>) => void;
35-
results: UserResponse<LocalUserType>[];
34+
onPress: (user: UserResponse<StreamChatType>) => void;
35+
results: UserResponse<StreamChatType>[];
3636
gridSize?: number;
3737
loading?: boolean;
3838
loadMore?: () => void;

0 commit comments

Comments
 (0)