Fix case where Conversation isn't returned and can't send message

This commit is contained in:
Moez Bhatti
2018-06-14 20:20:14 -04:00
parent 5ede84acf5
commit 6e14b1ab11
9 changed files with 152 additions and 115 deletions
+15 -14
View File
@@ -23,23 +23,24 @@ import io.realm.RealmObject
import io.realm.annotations.Index
import io.realm.annotations.PrimaryKey
open class Conversation : RealmObject() {
open class Conversation(
@PrimaryKey var id: Long = 0,
@Index var archived: Boolean = false,
@Index var blocked: Boolean = false,
var recipients: RealmList<Recipient> = RealmList(),
var count: Int = 0,
var date: Long = 0,
var snippet: String = "",
var read: Boolean = true,
var me: Boolean = false,
var draft: String = "",
@PrimaryKey var id: Long = 0
@Index var archived: Boolean = false
@Index var blocked: Boolean = false
var recipients: RealmList<Recipient> = RealmList()
var count: Int = 0
var date: Long = 0
var snippet: String = ""
var read: Boolean = true
var me: Boolean = false
var draft: String = ""
// For group chats, the user is allowed to set a custom title for the conversation
var name: String = ""
// For group chats, the user is allowed to set a custom title for the conversation
var name: String = ""
) : RealmObject() {
fun getTitle(): String {
return name.takeIf { it.isNotBlank() } ?: recipients.joinToString { recipient -> recipient.getDisplayName() }
}
}
+6 -6
View File
@@ -23,12 +23,12 @@ import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
import java.util.*
open class Recipient : RealmObject() {
@PrimaryKey var id: Long = 0
var address: String = ""
var contact: Contact? = null
var lastUpdate: Long = 0
open class Recipient(
@PrimaryKey var id: Long = 0,
var address: String = "",
var contact: Contact? = null,
var lastUpdate: Long = 0
) : RealmObject() {
/**
* Return a string that can be displayed to represent the name of this contact