@@ -146,6 +146,7 @@ export type ForwardedMessageProps<
146146 * e.g., user avatar (to which message belongs to) is only showed for last (bottom) message in group.
147147 */
148148 groupStyles : GroupType [ ] ;
149+ disabled ?: boolean ;
149150 /**
150151 * Custom message footer component
151152 */
@@ -161,6 +162,7 @@ export type ForwardedMessageProps<
161162 MessageReplies ?: React . ComponentType <
162163 MessageRepliesProps < At , Ch , Co , Ev , Me , Re , Us >
163164 > ;
165+ textBeforeAttachments ?: boolean ;
164166} ;
165167
166168/**
@@ -229,9 +231,20 @@ export const MessageContent = <
229231 showActionSheet,
230232 supportedReactions = emojiData ,
231233 threadList,
234+ textBeforeAttachments = false ,
235+ disabled : disabledFromProps ,
232236 } = props ;
233237
234- const { disabled } = useChannelContext < At , Ch , Co , Ev , Me , Re , Us > ( ) ;
238+ const { disabled : disabledFromContext } = useChannelContext <
239+ At ,
240+ Ch ,
241+ Co ,
242+ Ev ,
243+ Me ,
244+ Re ,
245+ Us
246+ > ( ) ;
247+ const disabled = disabledFromProps || disabledFromContext ;
235248 const {
236249 Attachment : ContextAttachment ,
237250 Message,
@@ -344,6 +357,53 @@ export const MessageContent = <
344357 return message . created_at ;
345358 } ;
346359
360+ const renderAttachments = ( ) => (
361+ < >
362+ { Array . isArray ( message . attachments ) &&
363+ message . attachments . map ( ( attachment , index ) => {
364+ // We handle files separately
365+ if (
366+ attachment . type === 'file' ||
367+ ( attachment . type === 'image' &&
368+ ! attachment . title_link &&
369+ ! attachment . og_scrape_url )
370+ ) {
371+ return null ;
372+ }
373+
374+ return (
375+ < Attachment < At >
376+ actionHandler = { handleAction }
377+ alignment = { alignment }
378+ attachment = { attachment }
379+ AttachmentActions = { AttachmentActions }
380+ Card = { Card }
381+ CardCover = { CardCover }
382+ CardFooter = { CardFooter }
383+ CardHeader = { CardHeader }
384+ FileAttachment = { FileAttachment }
385+ Giphy = { Giphy }
386+ key = { `${ message . id } -${ index } ` }
387+ UrlPreview = { UrlPreview }
388+ />
389+ ) ;
390+ } ) }
391+ { files . length > 0 && (
392+ < FileAttachmentGroup < At >
393+ alignment = { alignment }
394+ AttachmentActions = { AttachmentActions }
395+ AttachmentFileIcon = { AttachmentFileIcon }
396+ FileAttachment = { FileAttachment }
397+ files = { files }
398+ handleAction = { handleAction }
399+ messageId = { message . id }
400+ />
401+ ) }
402+ { images . length > 0 && (
403+ < Gallery < At > alignment = { alignment } images = { images } />
404+ ) }
405+ </ >
406+ ) ;
347407 return (
348408 < MessageContentProvider value = { context } >
349409 < Container
@@ -401,49 +461,7 @@ export const MessageContent = <
401461 { MessageHeader && < MessageHeader testID = 'message-header' { ...props } /> }
402462 { /* TODO: Look at this in production: Reason for collapsible: https://github.com/facebook/react-native/issues/12966 */ }
403463 < ContainerInner alignment = { alignment } collapsable = { false } >
404- { Array . isArray ( message . attachments ) &&
405- message . attachments . map ( ( attachment , index ) => {
406- // We handle files separately
407- if (
408- attachment . type === 'file' ||
409- ( attachment . type === 'image' &&
410- ! attachment . title_link &&
411- ! attachment . og_scrape_url )
412- ) {
413- return null ;
414- }
415-
416- return (
417- < Attachment < At >
418- actionHandler = { handleAction }
419- alignment = { alignment }
420- attachment = { attachment }
421- AttachmentActions = { AttachmentActions }
422- Card = { Card }
423- CardCover = { CardCover }
424- CardFooter = { CardFooter }
425- CardHeader = { CardHeader }
426- FileAttachment = { FileAttachment }
427- Giphy = { Giphy }
428- key = { `${ message . id } -${ index } ` }
429- UrlPreview = { UrlPreview }
430- />
431- ) ;
432- } ) }
433- { files . length > 0 && (
434- < FileAttachmentGroup < At >
435- alignment = { alignment }
436- AttachmentActions = { AttachmentActions }
437- AttachmentFileIcon = { AttachmentFileIcon }
438- FileAttachment = { FileAttachment }
439- files = { files }
440- handleAction = { handleAction }
441- messageId = { message . id }
442- />
443- ) }
444- { images . length > 0 && (
445- < Gallery < At > alignment = { alignment } images = { images } />
446- ) }
464+ { ! textBeforeAttachments && renderAttachments ( ) }
447465 < MessageTextContainer < At , Ch , Co , Ev , Me , Re , Us >
448466 alignment = { alignment }
449467 disabled = { message . status === 'failed' || message . type === 'error' }
@@ -456,6 +474,7 @@ export const MessageContent = <
456474 MessageText = { MessageText }
457475 openThread = { onOpenThread }
458476 />
477+ { textBeforeAttachments && renderAttachments ( ) }
459478 </ ContainerInner >
460479 { repliesEnabled && (
461480 < MessageReplies < At , Ch , Co , Ev , Me , Re , Us >
@@ -484,13 +503,16 @@ export const MessageContent = <
484503 canEditMessage = { canEditMessage }
485504 handleDelete = { handleDelete }
486505 handleEdit = { handleEdit }
506+ handleReaction = { handleReaction }
507+ message = { message }
487508 messageActions = { messageActions }
488509 openReactionPicker = { openReactionPicker }
489510 openThread = { onOpenThread }
490511 reactionsEnabled = { reactionsEnabled }
491512 ref = { actionSheetRef }
492513 repliesEnabled = { repliesEnabled }
493514 setActionSheetVisible = { setActionSheetVisible }
515+ supportedReactions = { emojiData }
494516 threadList = { threadList }
495517 />
496518 ) }
0 commit comments