useMediaList

A hook that flattens a list of messages into a flat array of media tiles for the MediaList grid. It keeps one tile per renderable image/video attachment, applying the same attachment rules the message list uses, and excludes scraped/OG link-preview attachments and non-media attachments.

Best Practices

  • Feed it the messages returned by the media search source rather than building tiles by hand.
  • Render the result in a grid FlatList, one tile per entry.
  • Expect one tile per attachment — a message with multiple media attachments yields multiple tiles.
  • Keep the messages reference stable across renders to avoid recomputing tiles.
  • Use the message on each tile when you need to open a gallery viewer or resolve the source message.

Parameters

ParameterDescriptionType
messagesThe messages to extract image/video attachments from.MessageResponse[]

Return type

Returns a flat array of MediaTile, one per image/video attachment.

attachment

The image/video attachment rendered by the tile.

Type
Attachment

message

The message the attachment belongs to.

Type
MessageResponse