Groups a flat comment list into threads, the same way getCommentThreadsState
and useCommentThreads do.
Use it on the flat list from getCommentsQueryState or useCommentsQuery
when you want threads, for example for comments read across several
documents in one query. Pass replies along with their parents: a thread is
assembled from one input, so group by anything else after threading, not
before.
A thread's parent is the comment with no parentCommentId; replies point at
the parent's id. Replies whose parent is missing from the input are
dropped, which is what happens when a parent is deleted but its replies have
not disappeared yet.
Threads come back in the order their parents appear in comments, so passing
the store's newest-first list gives newest-thread-first. Replies within a
thread are always oldest first, since that is reading order.
Groups a flat comment list into threads, the same way
getCommentThreadsStateanduseCommentThreadsdo.Use it on the flat list from
getCommentsQueryStateoruseCommentsQuerywhen you want threads, for example for comments read across several documents in one query. Pass replies along with their parents: a thread is assembled from one input, so group by anything else after threading, not before.A thread's parent is the comment with no
parentCommentId; replies point at the parent'sid. Replies whose parent is missing from the input are dropped, which is what happens when a parent is deleted but its replies have not disappeared yet.Threads come back in the order their parents appear in
comments, so passing the store's newest-first list gives newest-thread-first. Replies within a thread are always oldest first, since that is reading order.