diff --git a/core/src/main/kotlin/ch/dissem/bitmessage/entity/Plaintext.kt b/core/src/main/kotlin/ch/dissem/bitmessage/entity/Plaintext.kt index f7a2f24..d341b66 100644 --- a/core/src/main/kotlin/ch/dissem/bitmessage/entity/Plaintext.kt +++ b/core/src/main/kotlin/ch/dissem/bitmessage/entity/Plaintext.kt @@ -816,13 +816,17 @@ class Plaintext private constructor( } } -data class Conversation(val id: UUID, val subject: String, val messages: List) { +data class Conversation(val id: UUID, val subject: String, val messages: List<Plaintext>) : Serializable { val participants = messages .map { it.from } .filter { it.privateKey == null || it.isChan } .distinct() - val extract: String by lazy { messages.lastOrNull()?.text ?: "" } + val extract: String by lazy { + messages.firstOrNull { m -> m.labels.any { l -> l.type==Label.Type.UNREAD } }?.text + ?: messages.lastOrNull()?.text + ?: "" + } fun hasUnread() = messages.any { it.isUnread() } }