Revert bad RxJava conversion that prevented tracking data to be updated in UI

This commit is contained in:
arkon 2021-01-04 16:25:19 -05:00
parent efbefabb01
commit 2c9f8bb9ce

View File

@ -15,6 +15,8 @@ import eu.kanade.tachiyomi.util.system.toast
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll import kotlinx.coroutines.awaitAll
import rx.Subscription
import rx.android.schedulers.AndroidSchedulers
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
@ -31,7 +33,7 @@ class TrackPresenter(
private val loggedServices by lazy { trackManager.services.filter { it.isLogged } } private val loggedServices by lazy { trackManager.services.filter { it.isLogged } }
private var trackJob: Job? = null private var trackSubscription: Subscription? = null
private var searchJob: Job? = null private var searchJob: Job? = null
private var refreshJob: Job? = null private var refreshJob: Job? = null
@ -41,14 +43,17 @@ class TrackPresenter(
} }
private fun fetchTrackings() { private fun fetchTrackings() {
trackJob?.cancel() trackSubscription?.let { remove(it) }
trackJob = launchIO { trackSubscription = db.getTracks(manga)
val tracks = db.getTracks(manga).await() .asRxObservable()
trackList = loggedServices.map { service -> .map { tracks ->
TrackItem(tracks.find { it.sync_id == service.id }, service) loggedServices.map { service ->
TrackItem(tracks.find { it.sync_id == service.id }, service)
}
} }
view?.onNextTrackings(trackList) .observeOn(AndroidSchedulers.mainThread())
} .doOnNext { trackList = it }
.subscribeLatestCache(TrackController::onNextTrackings)
} }
fun refresh() { fun refresh() {