summaryrefslogtreecommitdiffstats
path: root/ui/src/components/post.tsx
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-03-05 15:10:46 -0500
committerDessalines <tyhou13@gmx.com>2020-03-05 15:10:46 -0500
commit858366c57b959c0b2bc6e2a43ca194084a1ff0d8 (patch)
tree8586bd9ed92d9f62f9e69251e264b738e6c166a6 /ui/src/components/post.tsx
parent25fa97a20af8ef244bc5e934670a3a81a4eff589 (diff)
Proper comment-node depth coloring.
Diffstat (limited to 'ui/src/components/post.tsx')
-rw-r--r--ui/src/components/post.tsx15
1 files changed, 13 insertions, 2 deletions
diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx
index faee23ed..e6b4a206 100644
--- a/ui/src/components/post.tsx
+++ b/ui/src/components/post.tsx
@@ -311,16 +311,27 @@ export class Post extends Component<any, PostState> {
}
let tree: Array<CommentNodeI> = [];
for (let comment of this.state.comments) {
+ let child = map.get(comment.id);
if (comment.parent_id) {
- map.get(comment.parent_id).children.push(map.get(comment.id));
+ let parent_ = map.get(comment.parent_id);
+ parent_.children.push(child);
} else {
- tree.push(map.get(comment.id));
+ tree.push(child);
}
+
+ this.setDepth(child);
}
return tree;
}
+ setDepth(node: CommentNodeI, i: number = 0): void {
+ for (let child of node.children) {
+ child.comment.depth = i;
+ this.setDepth(child, i + 1);
+ }
+ }
+
commentsTree() {
let nodes = this.buildCommentsTree();
return (