Improve message sync speed & reliability

This commit is contained in:
Moez Bhatti
2021-02-14 00:19:30 -05:00
parent bc6c19e080
commit ca1e7b7c7a
7 changed files with 81 additions and 45 deletions
@@ -36,7 +36,7 @@ class QkRealmMigration @Inject constructor(
) : RealmMigration {
companion object {
const val SchemaVersion: Long = 10
const val SchemaVersion: Long = 11
}
@SuppressLint("ApplySharedPref")
@@ -223,6 +223,17 @@ class QkRealmMigration @Inject constructor(
version++
}
if (version == 10L) {
realm.schema.get("MmsPart")
?.addField("messageId", Long::class.java, FieldAttribute.INDEXED, FieldAttribute.REQUIRED)
?.transform { part ->
val messageId = part.linkingObjects("Message", "parts").firstOrNull()?.getLong("contentId") ?: 0
part.setLong("messageId", messageId)
}
version++
}
check(version >= newVersion) { "Migration missing from v$oldVersion to v$newVersion" }
}