Improve thread rendering

This commit is contained in:
Paul Frazee 2022-12-18 18:54:05 -06:00
parent 69b86255c6
commit ae3099dfca
5 changed files with 194 additions and 101 deletions

View file

@ -90,14 +90,17 @@ export const PostThread = observer(function PostThread({
function* flattenThread(
post: PostThreadViewPostModel,
isAscending = false,
): Generator<PostThreadViewPostModel, void> {
if (post.parent) {
yield* flattenThread(post.parent)
yield* flattenThread(post.parent, true)
}
yield post
if (post.replies?.length) {
for (const reply of post.replies) {
yield* flattenThread(reply)
}
} else if (!isAscending && !post.parent && post.replyCount > 0) {
post._hasMore = true
}
}