@@ -25,6 +25,7 @@ import {
2525 Channel as StreamChannel ,
2626 StreamChat ,
2727 UpdatedMessage ,
28+ UserResponse ,
2829} from 'stream-chat' ;
2930import { v4 as uuidv4 } from 'uuid' ;
3031
@@ -451,7 +452,11 @@ const ChannelInner = <
451452 ) ;
452453
453454 const updateMessage = useCallback (
454- ( updatedMessage : StreamMessage < At , Ch , Co , Ev , Me , Re , Us > ) => {
455+ (
456+ updatedMessage :
457+ | MessageToSend < At , Ch , Co , Me , Re , Us >
458+ | StreamMessage < At , Ch , Co , Ev , Me , Re , Us > ,
459+ ) => {
455460 if ( ! channel ) return ;
456461 // adds the message to the local channel state..
457462 // this adds to both the main channel state as well as any reply threads
@@ -469,15 +474,36 @@ const ChannelInner = <
469474 [ channel , state . thread ] ,
470475 ) ;
471476
477+ const isUserResponseArray = (
478+ output : string [ ] | UserResponse < Us > [ ] ,
479+ ) : output is UserResponse < Us > [ ] =>
480+ ( output as UserResponse < Us > [ ] ) [ 0 ] ?. id != null ;
481+
472482 const doSendMessage = useCallback (
473- async ( message : StreamMessage < At , Ch , Co , Ev , Me , Re , Us > ) => {
483+ async (
484+ message :
485+ | MessageToSend < At , Ch , Co , Me , Re , Us >
486+ | StreamMessage < At , Ch , Co , Ev , Me , Re , Us > ,
487+ ) => {
474488 if ( ! channel ) return ;
475- const { attachments, id, mentioned_users, parent_id, text } = message ;
489+
490+ const {
491+ attachments,
492+ id,
493+ mentioned_users = [ ] ,
494+ parent_id,
495+ text,
496+ } = message ;
497+
498+ // channel.sendMessage expects an array of user id strings
499+ const mentions = isUserResponseArray ( mentioned_users )
500+ ? mentioned_users . map ( ( { id } ) => id )
501+ : mentioned_users ;
476502
477503 const messageData = {
478504 attachments,
479505 id,
480- mentioned_users,
506+ mentioned_users : mentions ,
481507 parent_id,
482508 text,
483509 } as Message < At , Me , Us > ;
@@ -524,10 +550,11 @@ const ChannelInner = <
524550 text : string ,
525551 attachments : MessageAttachments < At > ,
526552 parent : MessageResponse < At , Ch , Co , Me , Re , Us > | undefined ,
527- mentioned_users : string [ ] ,
553+ mentioned_users : UserResponse < Us > [ ] ,
528554 ) => {
529555 // create a preview of the message
530556 const clientSideID = `${ client . userID } -${ uuidv4 ( ) } ` ;
557+
531558 return ( {
532559 __html : text ,
533560 attachments,
0 commit comments