chore(common): updateAllExpanded -> setExpanded

This commit is contained in:
Harsh Shandilya 2022-12-13 11:37:41 +05:30
parent 4066a86ad6
commit da80605ae1
No known key found for this signature in database
2 changed files with 3 additions and 3 deletions

View file

@ -40,11 +40,11 @@ internal fun createListNode(comments: List<Comment>): MutableList<CommentNode> {
return commentNodes
}
internal fun updateAllExpanded(commentNode: CommentNode, expanded: Boolean): CommentNode {
internal fun setExpanded(commentNode: CommentNode, expanded: Boolean): CommentNode {
commentNode.isExpanded = expanded
if (commentNode.children.isNotEmpty()) {
commentNode.children.forEach { updateAllExpanded(it, expanded) }
commentNode.children.forEach { setExpanded(it, expanded) }
}
return commentNode
}

View file

@ -63,7 +63,7 @@ private fun CommentsPageInternal(
nodes = commentNodes,
htmlConverter = htmlConverter,
toggleExpanded = { node ->
val newNode = updateAllExpanded(node, !node.isExpanded)
val newNode = setExpanded(node, !node.isExpanded)
val parent = findTopMostParent(newNode)
val index =
commentNodes.indexOf(commentNodes.find { it.comment.url == parent.comment.url })