refactor(reader): Replace rx with kotlin coroutine

This commit is contained in:
Ahmad Ansori Palembani 2024-12-11 19:21:41 +07:00
parent 8e7f5d8897
commit b4e3dcfdda
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6

View file

@ -69,8 +69,6 @@ import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.flow.update import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import rx.Completable
import rx.schedulers.Schedulers
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
@ -1012,13 +1010,9 @@ class ReaderViewModel(
if (!chapter.chapter.read) return if (!chapter.chapter.read) return
val manga = manga ?: return val manga = manga ?: return
Completable viewModelScope.launchNonCancellableIO {
.fromCallable {
downloadManager.enqueueDeleteChapters(listOf(chapter.chapter), manga) downloadManager.enqueueDeleteChapters(listOf(chapter.chapter), manga)
} }
.onErrorComplete()
.subscribeOn(Schedulers.io())
.subscribe()
} }
/** /**
@ -1026,10 +1020,9 @@ class ReaderViewModel(
* are ignored. * are ignored.
*/ */
private fun deletePendingChapters() { private fun deletePendingChapters() {
Completable.fromCallable { downloadManager.deletePendingChapters() } viewModelScope.launchNonCancellableIO {
.onErrorComplete() downloadManager.deletePendingChapters()
.subscribeOn(Schedulers.io()) }
.subscribe()
} }
data class State( data class State(