Improve conversation class
* make it serializable * provide either first unread or last message as extract
This commit is contained in:
parent
81fc50ec37
commit
c7c285a2c1
@ -816,13 +816,17 @@ class Plaintext private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
data class Conversation(val id: UUID, val subject: String, val messages: List<Plaintext>) {
|
||||
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() }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user