From 2ab69de686fd5370dd9d7bd044df049c76e28ed1 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sun, 11 Dec 2022 12:53:55 +0530 Subject: [PATCH] fix(common): do not compute a new node if it cannot be used --- .../main/kotlin/dev/msfjarvis/claw/common/comments/Comments.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/Comments.kt b/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/Comments.kt index 442ddf2b..389fdd37 100644 --- a/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/Comments.kt +++ b/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/Comments.kt @@ -63,13 +63,12 @@ private fun CommentsPageInternal( nodes = commentNodes, htmlConverter = htmlConverter, toggleExpanded = { node -> - val newNode = toggleAllExpanded(node) // TODO(anunaym14): make this search recursive val index = commentNodes.indexOf(commentNodes.find { it.comment.url == node.comment.url }) if (index != -1) { commentNodes.removeAt(index) - commentNodes.add(index, newNode) + commentNodes.add(index, toggleAllExpanded(node)) } }, )