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(
75
75
* Available built-in component (also accepts the same props as): [Attachment](https://getstream.github.io/stream-chat-react-native/#attachment)
76
76
* */
77
77
Attachment : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . elementType ] ) ,
78
+ /**
79
+ * Override send message request (Advanced usage only)
80
+ * */
81
+ doSendMessageRequest : PropTypes . func ,
78
82
} ;
79
83
80
84
static defaultProps = {
Original file line number Diff line number Diff line change @@ -124,6 +124,8 @@ export class ChannelInner extends PureComponent {
124
124
isOnline : PropTypes . bool ,
125
125
Message : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . elementType ] ) ,
126
126
Attachment : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . elementType ] ) ,
127
+ /** Override send message request (Advanced usage only) */
128
+ doSendMessageRequest : PropTypes . func ,
127
129
} ;
128
130
129
131
static defaultProps = {
@@ -380,7 +382,16 @@ export class ChannelInner extends PureComponent {
380
382
} ;
381
383
382
384
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
+
384
395
// replace it after send is completed
385
396
if ( messageResponse . message ) {
386
397
messageResponse . message . status = 'received' ;
Original file line number Diff line number Diff line change @@ -141,6 +141,11 @@ export interface ChannelProps extends ChatContextValue {
141
141
EmptyStateIndicator ?: React . ElementType < EmptyStateIndicatorProps > ;
142
142
Message ?: React . ElementType < MessageUIComponentProps > ;
143
143
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 > ;
144
149
}
145
150
146
151
export type listType = 'channel' | 'message' | 'default' ;
You can’t perform that action at this time.
0 commit comments