1
+ import React , { useCallback , useMemo } from 'react' ;
1
2
import uniqBy from 'lodash.uniqby' ;
2
- import React , { ComponentType , useCallback , useMemo } from 'react' ;
3
+ import type { ComponentType } from 'react' ;
4
+ import type { Channel , MessageResponse , User } from 'stream-chat' ;
3
5
4
6
import { useSearchContext } from '../SearchContext' ;
5
7
import { Avatar } from '../../../components/Avatar' ;
6
8
import { ChannelPreview } from '../../../components/ChannelPreview' ;
7
9
import { useChannelListContext , useChatContext } from '../../../context' ;
8
-
9
10
import { DEFAULT_JUMP_TO_PAGE_SIZE } from '../../../constants/limits' ;
10
11
11
- import type { Channel , MessageResponse , User } from 'stream-chat' ;
12
- import type { DefaultStreamChatGenerics } from '../../../types' ;
13
-
14
- export type ChannelSearchResultItemProps <
15
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics ,
16
- > = {
17
- item : Channel < StreamChatGenerics > ;
12
+ export type ChannelSearchResultItemProps = {
13
+ item : Channel ;
18
14
} ;
19
15
20
- export const ChannelSearchResultItem = <
21
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics ,
22
- > ( {
23
- item,
24
- } : ChannelSearchResultItemProps < StreamChatGenerics > ) => {
25
- const { setActiveChannel } = useChatContext < StreamChatGenerics > ( ) ;
26
- const { setChannels } = useChannelListContext < StreamChatGenerics > ( ) ;
16
+ export const ChannelSearchResultItem = ( { item } : ChannelSearchResultItemProps ) => {
17
+ const { setActiveChannel } = useChatContext ( ) ;
18
+ const { setChannels } = useChannelListContext ( ) ;
27
19
28
20
const onSelect = useCallback ( ( ) => {
29
21
setActiveChannel ( item ) ;
@@ -39,24 +31,20 @@ export const ChannelSearchResultItem = <
39
31
) ;
40
32
} ;
41
33
42
- export type ChannelByMessageSearchResultItemProps <
43
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics ,
44
- > = {
45
- item : MessageResponse < StreamChatGenerics > ;
34
+ export type ChannelByMessageSearchResultItemProps = {
35
+ item : MessageResponse ;
46
36
} ;
47
37
48
- export const MessageSearchResultItem = <
49
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics ,
50
- > ( {
38
+ export const MessageSearchResultItem = ( {
51
39
item,
52
- } : ChannelByMessageSearchResultItemProps < StreamChatGenerics > ) => {
40
+ } : ChannelByMessageSearchResultItemProps ) => {
53
41
const {
54
42
channel : activeChannel ,
55
43
client,
56
44
searchController,
57
45
setActiveChannel,
58
- } = useChatContext < StreamChatGenerics > ( ) ;
59
- const { setChannels } = useChannelListContext < StreamChatGenerics > ( ) ;
46
+ } = useChatContext ( ) ;
47
+ const { setChannels } = useChannelListContext ( ) ;
60
48
61
49
const channel = useMemo ( ( ) => {
62
50
const { channel : channelData } = item ;
@@ -97,20 +85,14 @@ export const MessageSearchResultItem = <
97
85
) ;
98
86
} ;
99
87
100
- export type UserSearchResultItemProps <
101
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics ,
102
- > = {
103
- item : User < StreamChatGenerics > ;
88
+ export type UserSearchResultItemProps = {
89
+ item : User ;
104
90
} ;
105
91
106
- export const UserSearchResultItem = <
107
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics ,
108
- > ( {
109
- item,
110
- } : UserSearchResultItemProps < StreamChatGenerics > ) => {
111
- const { client, setActiveChannel } = useChatContext < StreamChatGenerics > ( ) ;
112
- const { setChannels } = useChannelListContext < StreamChatGenerics > ( ) ;
113
- const { directMessagingChannelType } = useSearchContext < StreamChatGenerics > ( ) ;
92
+ export const UserSearchResultItem = ( { item } : UserSearchResultItemProps ) => {
93
+ const { client, setActiveChannel } = useChatContext ( ) ;
94
+ const { setChannels } = useChannelListContext ( ) ;
95
+ const { directMessagingChannelType } = useSearchContext ( ) ;
114
96
115
97
const onClick = useCallback ( ( ) => {
116
98
const newChannel = client . channel ( directMessagingChannelType , {
0 commit comments