useFileAttachmentListSections
A hook that turns a list of messages into the month-grouped sections rendered by the FileAttachmentList. It gathers the file and audio attachments from each message (excluding scraped/OG link-preview content), groups them into newest-first month sections, and skips messages without renderable file attachments.
Best Practices
- Feed it the messages returned by the file attachment search source rather than building sections by hand.
- Render the result in a
SectionList, using each section'stitleas the sticky month header. - Customize the month label format through the
timestamp/FileAttachmentListSectiontranslation key instead of post-processing titles. - Expect one tile per attachment — a message with multiple file attachments yields multiple rows.
- Keep the
messagesreference stable across renders to avoid recomputing sections.
Parameters
| Parameter | Description | Type |
|---|---|---|
messages | The messages to extract file/audio attachments from. | MessageResponse[] |
Return type
Returns an array of FileAttachmentSection, ordered newest-first by month.
title
The localized month label for the section, used as its header.
| Type |
|---|
string |
data
The attachment tiles in the section. Each FileAttachmentTile is a { attachment, message } pair.
| Type |
|---|
FileAttachmentTile[] |