This API allows you to observe threads data within your application, that are visible to the current user, including live updates. You can use the available filter options to fine tune the threads returned.
When this is true, Cord is in the process of fetching additional data from its backend. Once the fetch is complete, the additional items will be appended to the result list, and loading will become false.
Both the initial data load and a call to fetchMore will start a fetch and cause loading to become true.
Call this function to fetch additional data from Cord's backend. It takes a single argument, the number of additional items to fetch.
Once called, loading will become true while the data is fetched. Once the fetch is complete, the additional items will be appended to the result list, and loading will return to false.
This function returns a promise that is resolved once the fetch is complete.
If this is true, then the list of results is incomplete, and you need to call fetchMore to continue paginating through them. Once this becomes false, all results are available, and calls to fetchMore won't do anything.
An array of objects containing the threads that match the request.
This array is paginated. At first, it will contain only the first few threads. Calling fetchMore will cause further threads to be appended to the array.
The order in which you will receive the threads is determined by the sorting options.
This is an array of objects, each of which has the following fields:
Contains information about the first (i.e., oldest) message in the thread. null if the thread is empty.
This is an object with the following fields:
seen
boolean
Whether the message has been seen by the current viewer.
id
string
The ID for the message. If a message is created with no ID, a random UUID-based ID will be automatically created for it.
authorID
string
The ID for the user that sent the message.
groupID
string
The ID for the group this message belongs to.
threadID
string
The ID for the thread this message is part of.
content
object[]
The content of the message.
plaintext
string
A plaintext version of the structured message content.
url
string | null
A URL where the message can be seen. This determines where a user is sent when they click on a reference to this message, such as in a notification. If unset, it defaults to the thread's URL.
createdTimestamp
Date
The timestamp when this message was created. The default value is the current time.
deletedTimestamp
Date | null
The timestamp when this message was deleted, if it was. If unset, the message is not deleted.
updatedTimestamp
Date | null
The timestamp when this message was last edited, if it ever was. If unset, the message does not show as edited.
iconURL
string | null
The URL of the icon to show next to the message. This is only used for action_message messages; other messages show the avatar of the author. If an action_message does not have an icon set, no icon is shown.
translationKey
string | null
An optional translation key used for this message. This is useful for system-generated messages where you might want to translate or customize them at runtime. See the translations documentation for more information.
type
"action_message" | "user_message"
The type of message this is. A user_message is a message that the author sent. An action_message is a message about something that happened, such as the thread being resolved. The default value is user_message.
metadata
EntityMetadata
Arbitrary key-value pairs that can be used to store additional information.
extraClassnames
string | null
A optional space separated list of classnames to add to the message.
attachments
array
The items attached to this message.
reactions
Reaction[]
The reactions to this message.
This is an array of objects, each of which has the following fields:
reaction
string
The emoji reaction.
userID
string
The ID of the user who reacted to the message.
timestamp
Date
The timestamp of when the reaction was created.
seenBy
string[]
A list of IDs of the users that have seen the message.
skipLinkPreviews
boolean
If set, Cord won't analyze links in the message to generate previews.
Contains information about the last (i.e., newest) message in the thread. null if the thread is empty.
This is an object with the following fields:
seen
boolean
Whether the message has been seen by the current viewer.
id
string
The ID for the message. If a message is created with no ID, a random UUID-based ID will be automatically created for it.
authorID
string
The ID for the user that sent the message.
groupID
string
The ID for the group this message belongs to.
threadID
string
The ID for the thread this message is part of.
content
object[]
The content of the message.
plaintext
string
A plaintext version of the structured message content.
url
string | null
A URL where the message can be seen. This determines where a user is sent when they click on a reference to this message, such as in a notification. If unset, it defaults to the thread's URL.
createdTimestamp
Date
The timestamp when this message was created. The default value is the current time.
deletedTimestamp
Date | null
The timestamp when this message was deleted, if it was. If unset, the message is not deleted.
updatedTimestamp
Date | null
The timestamp when this message was last edited, if it ever was. If unset, the message does not show as edited.
iconURL
string | null
The URL of the icon to show next to the message. This is only used for action_message messages; other messages show the avatar of the author. If an action_message does not have an icon set, no icon is shown.
translationKey
string | null
An optional translation key used for this message. This is useful for system-generated messages where you might want to translate or customize them at runtime. See the translations documentation for more information.
type
"action_message" | "user_message"
The type of message this is. A user_message is a message that the author sent. An action_message is a message about something that happened, such as the thread being resolved. The default value is user_message.
metadata
EntityMetadata
Arbitrary key-value pairs that can be used to store additional information.
extraClassnames
string | null
A optional space separated list of classnames to add to the message.
attachments
array
The items attached to this message.
reactions
Reaction[]
The reactions to this message.
This is an array of objects, each of which has the following fields:
reaction
string
The emoji reaction.
userID
string
The ID of the user who reacted to the message.
timestamp
Date
The timestamp of when the reaction was created.
seenBy
string[]
A list of IDs of the users that have seen the message.
skipLinkPreviews
boolean
If set, Cord won't analyze links in the message to generate previews.
All of the users who are engaging in this thread. This includes both subscribed and unsubscribed users.
This is an array of objects, each of which has the following fields:
lastSeenTimestamp
Date | null
The timestamp of the most recent message or reaction that this user has seen in this thread. Is null if this participant has never viewed this thread.
userID
string | null
The user ID of the participant. Can be null if the current viewer no longer shares a group with this participant (and therefore can no longer access that participant's information).
The users that are currently typing in this thread. Typing status is transient in nature, so the value is the set of users typing at a particular instant, but may change rapidly.
The name of the thread. This is shown to users when the thread is referenced, such as in notifications. This should generally be something like the page title.
A URL where the thread can be seen. This determines where a user is sent when they click on a reference to this thread, such as in a notification, or if they click on a reference to a message in the thread and the message doesn't have its own URL.
The number of threads that have messages the current user hasn't seen yet and is subscribed to.
A user is automatically subscribed to threads relevant to them, for example because they have sent a message or have been @-mentioned in them. unreadSubscribed is always less than or equal to unread.
The hook will return an object containing the fields described under "Available Data" above. The component will automatically re-render if any of the data changes, i.e., this data is always "live".
This option controls the criteria for how threads are sorted. Combined with sortDirection, it determines which threads are "first".
It's a string enum which can have one of the following values:
first_message_timestamp: sort threads by the timestamp of the first message in the thread. In other words, threads will be sorted based on how recently they were created.
most_recent_message_timestamp: sort threads by the timestamp of the most recent message in the thread. In other words, threads will be sorted based on how recently they were responded to.
If true, perform partial matching on the specified location. If false, fetch information for only exactly the location specified.
resolvedStatus
optional
"resolved" | "any" | "unresolved"
If set to resolved, only resolved threads will be returned. If set to unresolved, only unresolved threads will be returned. If set to any, both resolved and unresolved threads will be returned.
If unset, defaults to any.
metadata
optional
EntityMetadata
The value for a metadata entry should be an object representing the metadata key/value to filter on. For example, to show only threads with the metadata key of "category" set to "sales", set the filter to { metadata: { category: "sales" } }.