fix(common): reintroduce handling for first views for comment state

This commit is contained in:
Harsh Shandilya 2024-08-24 16:02:29 +05:30
parent 1dfcda4a64
commit 1cbd3b5bd0

View file

@ -40,8 +40,12 @@ internal fun createListNode(
comments: List<Comment>,
commentState: PostComments,
): MutableList<CommentNode> {
// Only check unread state if there any comments read in the first place. This somewhat restores
// the first view behavior from when `commentState` was nullable.
val hasUnread = commentState.commentIds.isNotEmpty()
val isUnread =
if (hasUnread) ({ id: String -> !commentState.commentIds.contains(id) }) else { _ -> false }
val commentNodes = mutableListOf<CommentNode>()
val isUnread = { id: String -> !commentState.commentIds.contains(id) }
for (i in comments.indices) {
if (comments[i].parentComment == null) {