forked from upstream-mirrors/quik
Upgrade Realm, use new query predicates for loading conversations
This commit is contained in:
@@ -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) }
|
||||
|
||||
@@ -30,12 +30,12 @@ import data.model.MenuItem
|
||||
import data.model.SyncLog
|
||||
import data.repository.MessageRepository
|
||||
import interactor.*
|
||||
import presentation.Navigator
|
||||
import presentation.common.base.QkViewModel
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.rxkotlin.withLatestFrom
|
||||
import io.realm.Realm
|
||||
import presentation.Navigator
|
||||
import presentation.common.base.QkViewModel
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -77,7 +77,7 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
|
||||
.distinctUntilChanged()
|
||||
.subscribe { syncing -> newState { it.copy(syncing = syncing) } }
|
||||
|
||||
newState { it.copy(page = Inbox(data = messageRepo.getConversations())) }
|
||||
newState { it.copy(page = Inbox(data = conversations)) }
|
||||
|
||||
val isDefaultSms = Telephony.Sms.getDefaultSmsPackage(context) != context.packageName
|
||||
val hasSmsPermission = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_SMS) == PackageManager.PERMISSION_GRANTED
|
||||
|
||||
Reference in New Issue
Block a user