Files
react-native-chat-ui/docs/types.md
Alex Demchenko e90047512e Add docs
2021-03-24 00:00:44 +01:00

4.2 KiB

id, title
id title
types Types

There are 3 supported message types at the moment - File, Image and Text. All of them have corresponding "partial" message types, that include only the message's content. "Partial" messages are useful to create the content and then pass it to some kind of a backend service, which will assign fields like id or authorId etc, returning a "full" message which can be passed to messages prop of the <Chat />.

Base

All messages should have this, most of these fields will be set by the backend service (you can set type and maybe an error or sending status).

:::note

Question mark shows optional types.

:::

Name Type Description
authorId string Message's author
id string Message's ID
status? delivered error read sending Message's status
timestamp? number Timestamp in seconds
type file image text Message's type

Partial file

Name Type Description
fileName string File's name
mimeType? string File's MIME type
size number Size in bytes
uri string Supports both local resource and remote URL

File

File message is a combination of base and partial file types, where the base's type is set to file. This is what the chat expects in the messages array.

Partial image

Even though height and width are optional, we recommend setting those (because you will anyway have them from the image picker) for a better overall look and feel, since the placeholder of this size will be rendered and when the image is available it will just replace it.

Name Type Description
height? number Image's height
imageName string Image's name
size number Size in bytes
uri string Supports both local resource and remote URL
width? number Image's width

Image

Image message is a combination of base and partial image types, where the base's type is set to image. This is what the chat expects in the messages array.

Partial text

Name Type Description
previewData? PreviewData You shouldn't probably set this field directly, use onPreviewDataFetched callback
text string Text

Text

Text message is a combination of base and partial text types, where the base's type is set to text. This is what the chat expects in the messages array.

User

The only required field for the user is the id, used to determine the message author, however, you can pass additional data if you will want to render all available users for the chat or a conversation tile.

Name Type Description
avatarUrl? string User's avatar remote URL
firstName? string User's first name
id string Unique ID
lastName? string User's last name