From 1cbd3b5bd0940cbee5098dac1e164f17cf09e669 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sat, 24 Aug 2024 16:02:29 +0530 Subject: [PATCH] fix(common): reintroduce handling for first views for comment state --- .../dev/msfjarvis/claw/common/comments/CommentNode.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentNode.kt b/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentNode.kt index 86b4e027..71a045c3 100644 --- a/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentNode.kt +++ b/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentNode.kt @@ -40,8 +40,12 @@ internal fun createListNode( comments: List, commentState: PostComments, ): MutableList { + // 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() - val isUnread = { id: String -> !commentState.commentIds.contains(id) } for (i in comments.indices) { if (comments[i].parentComment == null) {