Upgrade Realm, use new query predicates for loading conversations

This commit is contained in:
Moez Bhatti
2018-01-02 17:40:31 -05:00
parent 8bc545bb2c
commit 487d90cf6b
4 changed files with 10 additions and 14 deletions
@@ -65,14 +65,10 @@ class MessageRepository @Inject constructor(
.filter { it.isLoaded }
.map { realm.copyFromRealm(it) }
// Adding the #distinct() call makes this call approx 20x slower
// With ~70,000 messages on a Google Pixel, it goes from 15ms -> 300ms
// This should be fixed by using Realm 4.3, but that breaks the build
// Will fix
val messageFlowable = realm.where(Message::class.java)
.findAllSortedAsync("date", Sort.DESCENDING)
.where()
.distinctAsync("threadId")
.sort("date", Sort.DESCENDING)
.distinctValues("threadId")
.findAllAsync()
.asFlowable()
.filter { it.isLoaded }
.map { realm.copyFromRealm(it) }