enhancement: retain comment expanded state when loading more or refreshing (#1012)

This commit is contained in:
N7-X 2024-06-21 10:23:14 -04:00 committed by GitHub
parent 1d9aeba452
commit 65c03c635c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -479,7 +479,9 @@ class PostDetailViewModel(
.populateLoadMoreComments()
.map {
it.copy(
expanded = autoExpandComments,
// retain comment expand state if refreshing or loading more
expanded = currentState.comments.firstOrNull() { comment -> comment.id == it.id }?.expanded
?: autoExpandComments,
// only first level are visible and can be expanded
visible = autoExpandComments || it.depth == 0,
)