FunctionThe document to read, optionally narrowed by fieldPath or status
The matching threads, and whether a switch is in flight
function Threads({documentId}: {documentId: string}) {
const {threads} = useCommentThreads({
documentId,
documentType: 'article',
status: 'open',
})
return (
<ul>
{threads.map((thread) => (
<li key={thread.threadId}>
{thread.fieldPath || 'Document'} — {thread.commentsCount} comments
</li>
))}
</ul>
)
}
Reads a document's comments grouped into threads.
A thread is one comment plus its replies. Its
statusandfieldPathcome from the first comment, so filtering by either selects whole threads rather than stray replies.Unlike the Studio, every thread is returned. The Studio hides threads whose field has left the schema or is hidden by a conditional, which it can do because it has the schema to check against. Inspect
fieldPathyourself if your app needs to do the same.