Commit f8975ff0 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update RealmSpotlightRepository.kt

parent b4242e30
......@@ -10,7 +10,6 @@ import chat.rocket.persistence.realm.models.ddp.RealmSpotlight.Columns
import hu.akarnokd.rxjava.interop.RxJavaInterop
import io.reactivex.Flowable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.realm.Case
import io.realm.Realm
import io.realm.RealmResults
import io.realm.Sort
......@@ -20,7 +19,7 @@ class RealmSpotlightRepository(private val hostname: String) : RealmRepository()
override fun getSuggestionsFor(term: String, limit: Int): Flowable<List<Spotlight>> {
return Flowable.defer { Flowable.using<RealmResults<RealmSpotlight>, Pair<Realm, Looper>>({
Pair<Realm, Looper>(RealmStore.getRealm(hostname), Looper.myLooper())
Pair(RealmStore.getRealm(hostname), Looper.myLooper())
}, { pair -> RxJavaInterop.toV2Flowable<RealmResults<RealmSpotlight>>(pair.first.where(RealmSpotlight::class.java)
.findAllSorted(Columns.TYPE, Sort.DESCENDING)
.asObservable())
......@@ -35,7 +34,7 @@ class RealmSpotlightRepository(private val hostname: String) : RealmRepository()
val total = realmSpotlightList.size
val spotlightList = ArrayList<Spotlight>(total)
(0..total - 1).mapTo(spotlightList) {
(0 until total).mapTo(spotlightList) {
realmSpotlightList[it].asSpotlight()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment