11import React from 'react' ;
22
3- import type { Attachment as AttachmentType } from 'stream-chat' ;
3+ import type { Attachment as AttachmentType , ExtendableGenerics } from 'stream-chat' ;
44
55import { AttachmentActions as AttachmentActionsDefault } from '../../components/Attachment/AttachmentActions' ;
66import { Card as CardDefault } from '../../components/Attachment/Card' ;
@@ -12,47 +12,26 @@ import {
1212 useMessagesContext ,
1313} from '../../contexts/messagesContext/MessagesContext' ;
1414
15- import type {
16- DefaultAttachmentType ,
17- DefaultChannelType ,
18- DefaultCommandType ,
19- DefaultEventType ,
20- DefaultMessageType ,
21- DefaultReactionType ,
22- DefaultUserType ,
23- UnknownType ,
24- } from '../../types/types' ;
15+ import type { DefaultStreamChatGenerics } from '../../types/types' ;
2516
2617export type ActionHandler = ( name : string , value : string ) => void ;
2718
2819export type AttachmentPropsWithContext <
29- At extends UnknownType = DefaultAttachmentType ,
30- Ch extends UnknownType = DefaultChannelType ,
31- Co extends string = DefaultCommandType ,
32- Ev extends UnknownType = DefaultEventType ,
33- Me extends UnknownType = DefaultMessageType ,
34- Re extends UnknownType = DefaultReactionType ,
35- Us extends UnknownType = DefaultUserType ,
20+ StreamChatClient extends ExtendableGenerics = DefaultStreamChatGenerics ,
3621> = Pick <
37- MessagesContextValue < At , Ch , Co , Ev , Me , Re , Us > ,
22+ MessagesContextValue < StreamChatClient > ,
3823 'AttachmentActions' | 'Card' | 'FileAttachment' | 'Gallery' | 'Giphy' | 'UrlPreview'
3924> & {
4025 /**
4126 * The attachment to render
4227 */
43- attachment : AttachmentType < At > ;
28+ attachment : AttachmentType < StreamChatClient > ;
4429} ;
4530
4631const AttachmentWithContext = <
47- At extends UnknownType = DefaultAttachmentType ,
48- Ch extends UnknownType = DefaultChannelType ,
49- Co extends string = DefaultCommandType ,
50- Ev extends UnknownType = DefaultEventType ,
51- Me extends UnknownType = DefaultMessageType ,
52- Re extends UnknownType = DefaultReactionType ,
53- Us extends UnknownType = DefaultUserType ,
32+ StreamChatClient extends ExtendableGenerics = DefaultStreamChatGenerics ,
5433> (
55- props : AttachmentPropsWithContext < At , Ch , Co , Ev , Me , Re , Us > ,
34+ props : AttachmentPropsWithContext < StreamChatClient > ,
5635) => {
5736 const { attachment, AttachmentActions, Card, FileAttachment, Gallery, Giphy, UrlPreview } = props ;
5837
@@ -103,17 +82,9 @@ const AttachmentWithContext = <
10382 }
10483} ;
10584
106- const areEqual = <
107- At extends UnknownType = DefaultAttachmentType ,
108- Ch extends UnknownType = DefaultChannelType ,
109- Co extends string = DefaultCommandType ,
110- Ev extends UnknownType = DefaultEventType ,
111- Me extends UnknownType = DefaultMessageType ,
112- Re extends UnknownType = DefaultReactionType ,
113- Us extends UnknownType = DefaultUserType ,
114- > (
115- prevProps : AttachmentPropsWithContext < At , Ch , Co , Ev , Me , Re , Us > ,
116- nextProps : AttachmentPropsWithContext < At , Ch , Co , Ev , Me , Re , Us > ,
85+ const areEqual = < StreamChatClient extends ExtendableGenerics = DefaultStreamChatGenerics > (
86+ prevProps : AttachmentPropsWithContext < StreamChatClient > ,
87+ nextProps : AttachmentPropsWithContext < StreamChatClient > ,
11788) => {
11889 const { attachment : prevAttachment } = prevProps ;
11990 const { attachment : nextAttachment } = nextProps ;
@@ -132,34 +103,20 @@ const MemoizedAttachment = React.memo(
132103) as typeof AttachmentWithContext ;
133104
134105export type AttachmentProps <
135- At extends UnknownType = DefaultAttachmentType ,
136- Ch extends UnknownType = DefaultChannelType ,
137- Co extends string = DefaultCommandType ,
138- Ev extends UnknownType = DefaultEventType ,
139- Me extends UnknownType = DefaultMessageType ,
140- Re extends UnknownType = DefaultReactionType ,
141- Us extends UnknownType = DefaultUserType ,
106+ StreamChatClient extends ExtendableGenerics = DefaultStreamChatGenerics ,
142107> = Partial <
143108 Pick <
144- MessagesContextValue < At , Ch , Co , Ev , Me , Re , Us > ,
109+ MessagesContextValue < StreamChatClient > ,
145110 'AttachmentActions' | 'Card' | 'FileAttachment' | 'Gallery' | 'Giphy' | 'UrlPreview'
146111 >
147112> &
148- Pick < AttachmentPropsWithContext < At , Ch , Co , Ev , Me , Re , Us > , 'attachment' > ;
113+ Pick < AttachmentPropsWithContext < StreamChatClient > , 'attachment' > ;
149114
150115/**
151116 * Attachment - The message attachment
152117 */
153- export const Attachment = <
154- At extends UnknownType = DefaultAttachmentType ,
155- Ch extends UnknownType = DefaultChannelType ,
156- Co extends string = DefaultCommandType ,
157- Ev extends UnknownType = DefaultEventType ,
158- Me extends UnknownType = DefaultMessageType ,
159- Re extends UnknownType = DefaultReactionType ,
160- Us extends UnknownType = DefaultUserType ,
161- > (
162- props : AttachmentProps < At , Ch , Co , Ev , Me , Re , Us > ,
118+ export const Attachment = < StreamChatClient extends ExtendableGenerics = DefaultStreamChatGenerics > (
119+ props : AttachmentProps < StreamChatClient > ,
163120) => {
164121 const {
165122 attachment,
@@ -178,7 +135,7 @@ export const Attachment = <
178135 Gallery : ContextGallery ,
179136 Giphy : ContextGiphy ,
180137 UrlPreview : ContextUrlPreview ,
181- } = useMessagesContext < At , Ch , Co , Ev , Me , Re , Us > ( ) ;
138+ } = useMessagesContext < StreamChatClient > ( ) ;
182139
183140 if ( ! attachment ) {
184141 return null ;
0 commit comments