diff --git a/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentEntry.kt b/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentEntry.kt index 602ed431..1e967d2c 100644 --- a/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentEntry.kt +++ b/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentEntry.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2021-2022 Harsh Shandilya. + * Copyright © 2021-2023 Harsh Shandilya. * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. @@ -31,8 +31,11 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.text.AnnotatedString +import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.buildAnnotatedString +import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp import dev.msfjarvis.claw.common.posts.PostActions import dev.msfjarvis.claw.common.posts.PostTitle @@ -157,6 +160,7 @@ internal fun CommentEntry( buildCommenterString( commenterName = comment.user.username, score = comment.score, + isUnread = commentNode.isUnread, createdAt = comment.createdAt, updatedAt = comment.updatedAt, ), @@ -181,6 +185,7 @@ internal fun CommentEntry( fun buildCommenterString( commenterName: String, score: Int, + isUnread: Boolean, createdAt: TemporalAccessor, updatedAt: TemporalAccessor, ): AnnotatedString { @@ -219,5 +224,17 @@ fun buildCommenterString( append(updatedRelative.toString()) append(')') } + if (isUnread) { + append(' ') + withStyle( + style = + SpanStyle( + fontWeight = FontWeight.Bold, + color = MaterialTheme.colorScheme.error, + ) + ) { + append("(unread)") + } + } } } 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 41f39515..d452cc2b 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 @@ -1,5 +1,5 @@ /* - * Copyright © 2022 Harsh Shandilya. + * Copyright © 2022-2023 Harsh Shandilya. * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. @@ -8,13 +8,15 @@ package dev.msfjarvis.claw.common.comments import androidx.compose.foundation.lazy.LazyListScope import androidx.compose.material3.Divider +import dev.msfjarvis.claw.database.local.PostComments import dev.msfjarvis.claw.model.Comment internal data class CommentNode( val comment: Comment, var parent: CommentNode? = null, val children: MutableList = mutableListOf(), - var isExpanded: Boolean = true + val isUnread: Boolean = false, + var isExpanded: Boolean = true, ) { fun addChild(child: CommentNode) { if (comment.indentLevel + 1 == child.comment.indentLevel) {