mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 18:47:03 +05:30
comments: Update isExpanded based on the parent node being toggled (Fixes #352)
This commit is contained in:
parent
0f595f7b02
commit
4066a86ad6
2 changed files with 4 additions and 4 deletions
|
@ -40,11 +40,11 @@ internal fun createListNode(comments: List<Comment>): MutableList<CommentNode> {
|
|||
return commentNodes
|
||||
}
|
||||
|
||||
internal fun toggleAllExpanded(commentNode: CommentNode): CommentNode {
|
||||
commentNode.isExpanded = !commentNode.isExpanded
|
||||
internal fun updateAllExpanded(commentNode: CommentNode, expanded: Boolean): CommentNode {
|
||||
commentNode.isExpanded = expanded
|
||||
|
||||
if (commentNode.children.isNotEmpty()) {
|
||||
commentNode.children.forEach { toggleAllExpanded(it) }
|
||||
commentNode.children.forEach { updateAllExpanded(it, expanded) }
|
||||
}
|
||||
return commentNode
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ private fun CommentsPageInternal(
|
|||
nodes = commentNodes,
|
||||
htmlConverter = htmlConverter,
|
||||
toggleExpanded = { node ->
|
||||
val newNode = toggleAllExpanded(node)
|
||||
val newNode = updateAllExpanded(node, !node.isExpanded)
|
||||
val parent = findTopMostParent(newNode)
|
||||
val index =
|
||||
commentNodes.indexOf(commentNodes.find { it.comment.url == parent.comment.url })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue