Skip to main content

Overview

useFetchManyChatMessagesWrapper is a stateful wrapper around useFetchManyChatMessages that manages the message list and cursor pagination for you. It keeps results in local component state — not Redux — and never receives socket updates. Use it for a read-only or filtered list of messages that should not be touched by live traffic — for example, a “messages with replies” panel, an admin/moderation view, or any custom message list outside the live conversation stream. For the live canonical conversation view, use useLiveChatMessages instead.
This is a point-in-time query: it does not auto-update from socket events. Call refetch (e.g. on a refresh button, or on a socket signal of your choosing) to pick up new matches. It does not require ChatProvider.

Usage Example

Props

string
required
The ID of the conversation to query.
string | null
Restrict to thread replies of this message.
number
Page size. Defaults to 50.
"asc" | "desc"
Sort by creation time. Defaults to "desc" (newest first), where loadMore fetches older messages. With "asc", loadMore fetches newer messages.
ChatMessageListIncludeParam
Fields to add to each message, as a single value or an array:
  • "files" — the files field.
  • "grants" — the reputation-grant summary at message.grants: { total, count, viewerTotal } over positive grants. Populated by the reputation bundle; on a project without it the summary comes back zero-filled rather than missing.
MessageFilters
Optional filters. filters.hasReplies (boolean): when true, returns only messages that have thread replies (threadReplyCount > 0); when false, only messages with none. Filters by thread replies, not quotings.
Threads are one level deep, so hasReplies: true together with parentMessageId always yields an empty list. This wrapper exposes only messages; use the lower-level useFetchManyChatMessages if you want the notice explaining why.

Returns

ChatMessage[]
The loaded messages. See ChatMessage.
boolean
true while a fetch is in progress.
SublayError | null
The last load failure, or null. Cleared when the next load starts; loadMore() retries it. A SublayError.
boolean
true while loadMore() has something to fetch: a next page, or a load that failed.
() => Promise<void>
Loads the next page in the direction of sortDir and appends it: older messages with "desc" (the default), newer ones with "asc". Retries the load that failed instead, when there is one. Does nothing while loading or when there is nothing more. Never rejects: a failure lands in error.
() => Promise<void>
Reloads the first page (e.g. to pick up new matches). The loaded messages stay until the new first page replaces them. Never rejects: a failure lands in error.