fix load more comments on last comment (#510)

This commit is contained in:
Diego Beraldin 2024-02-07 20:52:35 +01:00 committed by GitHub
parent bb3b057e99
commit cc81885754
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,7 +5,7 @@ import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.CommentModel
internal fun List<CommentModel>.populateLoadMoreComments() = mapIndexed { idx, comment -> internal fun List<CommentModel>.populateLoadMoreComments() = mapIndexed { idx, comment ->
val hasMoreComments = (comment.comments ?: 0) > 0 val hasMoreComments = (comment.comments ?: 0) > 0
val isNextCommentNotChild = val isNextCommentNotChild =
idx < lastIndex && this[idx + 1].depth <= comment.depth (idx < lastIndex && this[idx + 1].depth <= comment.depth) || idx == lastIndex
comment.copy(loadMoreButtonVisible = hasMoreComments && isNextCommentNotChild) comment.copy(loadMoreButtonVisible = hasMoreComments && isNextCommentNotChild)
} }