File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed
Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,10 @@ const Channel = withChatContext(
7575 * Available built-in component (also accepts the same props as): [Attachment](https://getstream.github.io/stream-chat-react-native/#attachment)
7676 * */
7777 Attachment : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . elementType ] ) ,
78+ /**
79+ * Override send message request (Advanced usage only)
80+ * */
81+ doSendMessageRequest : PropTypes . func ,
7882 } ;
7983
8084 static defaultProps = {
Original file line number Diff line number Diff line change @@ -124,6 +124,8 @@ export class ChannelInner extends PureComponent {
124124 isOnline : PropTypes . bool ,
125125 Message : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . elementType ] ) ,
126126 Attachment : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . elementType ] ) ,
127+ /** Override send message request (Advanced usage only) */
128+ doSendMessageRequest : PropTypes . func ,
127129 } ;
128130
129131 static defaultProps = {
@@ -380,7 +382,16 @@ export class ChannelInner extends PureComponent {
380382 } ;
381383
382384 try {
383- const messageResponse = await this . props . channel . sendMessage ( messageData ) ;
385+ let messageResponse ;
386+ if ( this . props . doSendMessageRequest ) {
387+ messageResponse = await this . props . doSendMessageRequest (
388+ this . props . channel . cid ,
389+ messageData ,
390+ ) ;
391+ } else {
392+ messageResponse = await this . props . channel . sendMessage ( messageData ) ;
393+ }
394+
384395 // replace it after send is completed
385396 if ( messageResponse . message ) {
386397 messageResponse . message . status = 'received' ;
Original file line number Diff line number Diff line change @@ -141,6 +141,11 @@ export interface ChannelProps extends ChatContextValue {
141141 EmptyStateIndicator ?: React . ElementType < EmptyStateIndicatorProps > ;
142142 Message ?: React . ElementType < MessageUIComponentProps > ;
143143 Attachment ?: React . ElementType < AttachmentProps > ;
144+ /** Function that overrides default sendMessage if chat client */
145+ doSendMessageRequest ?(
146+ channelId : string ,
147+ message : Client . Message ,
148+ ) : void | Promise < Client . MessageResponse > ;
144149}
145150
146151export type listType = 'channel' | 'message' | 'default' ;
You can’t perform that action at this time.
0 commit comments