fix(common): do not compute a new node if it cannot be used

This commit is contained in:
Harsh Shandilya 2022-12-11 12:53:55 +05:30
parent 0083aa69b5
commit 2ab69de686
No known key found for this signature in database

View file

@ -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))
}
},
)