quote links are clickable, added on replies

This commit is contained in:
plebbitor
2023-03-08 09:49:42 +01:00
parent 8f160eed57
commit 47390fce99
3 changed files with 87 additions and 36 deletions
+17
View File
@@ -0,0 +1,17 @@
function renderThreadComments(comments) {
const commentKeys = Object.keys(comments);
const renderedComments = commentKeys.map(key => {
const comment = comments[key];
const { replies: { pages: { topAll: { comments: nestedComments } } } } = comment;
if (comment.replyCount > 0 && nestedComments) {
const renderedNestedComments = renderThreadComments(nestedComments);
return [comment, ...renderedNestedComments];
}
return [comment];
}).flat();
const sortedComments = renderedComments.sort((a, b) => a.timestamp - b.timestamp);
return sortedComments;
}
export default renderThreadComments;