Remove link between messages and conversations

This commit is contained in:
Moez Bhatti
2018-03-29 00:35:27 -04:00
parent d26adad7bf
commit ca548d97fb
19 changed files with 112 additions and 96 deletions
+5 -1
View File
@@ -28,9 +28,13 @@ import java.util.*
open class Conversation : RealmObject() {
@PrimaryKey var id: Long = 0
var recipients: RealmList<Recipient> = RealmList()
@Index var archived: Boolean = false
@Index var blocked: Boolean = false
var recipients: RealmList<Recipient> = RealmList()
var date: Long = 0
var snippet: String = ""
var read: Boolean = true
var me: Boolean = false
var draft: String = ""
fun getTitle() = recipients.joinToString { recipient ->
+2 -15
View File
@@ -32,19 +32,7 @@ open class Message : RealmObject() {
@PrimaryKey var id: Long = 0
var conversation: Conversation? = null
set(value) {
field = value
threadId = value?.id ?: 0
}
/**
* This is a hack so that we can index by the threadId, and return distinct threadIds when
* querying for all conversations for the MainActivity
*/
@Index
@Deprecated("This is only here for Realm to access - it should be ignored in our codebase")
var threadId: Long = 0
@Index var threadId: Long = 0
// The MMS-SMS content provider returns messages where duplicate ids can exist. This is because
// SMS and MMS are stored in separate tables. We can't use these ids as our realm message id
@@ -136,8 +124,7 @@ open class Message : RealmObject() {
.mapNotNull { it.text }
.joinToString("\n") { text -> text }
.takeIf { it.isNotEmpty() }
?: getCleansedSubject()
.takeIf { it.isNotEmpty() }
?: getCleansedSubject().takeIf { it.isNotEmpty() }
?: "An MMS message"
}
}