Remove unnecessary withIOContext

This commit is contained in:
arkon 2023-03-28 18:16:43 -04:00
parent 1814b3b22c
commit d1bf857079

View File

@ -9,7 +9,6 @@ import androidx.compose.ui.unit.dp
import androidx.paging.Pager import androidx.paging.Pager
import androidx.paging.PagingConfig import androidx.paging.PagingConfig
import androidx.paging.cachedIn import androidx.paging.cachedIn
import androidx.paging.filter
import androidx.paging.map import androidx.paging.map
import cafe.adriel.voyager.core.model.StateScreenModel import cafe.adriel.voyager.core.model.StateScreenModel
import cafe.adriel.voyager.core.model.coroutineScope import cafe.adriel.voyager.core.model.coroutineScope
@ -32,7 +31,6 @@ import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.update import kotlinx.coroutines.flow.update
@ -41,7 +39,6 @@ import logcat.LogPriority
import tachiyomi.core.preference.CheckboxState import tachiyomi.core.preference.CheckboxState
import tachiyomi.core.preference.mapAsCheckboxState import tachiyomi.core.preference.mapAsCheckboxState
import tachiyomi.core.util.lang.launchIO import tachiyomi.core.util.lang.launchIO
import tachiyomi.core.util.lang.withIOContext
import tachiyomi.core.util.system.logcat import tachiyomi.core.util.system.logcat
import tachiyomi.domain.category.interactor.GetCategories import tachiyomi.domain.category.interactor.GetCategories
import tachiyomi.domain.category.interactor.SetMangaCategories import tachiyomi.domain.category.interactor.SetMangaCategories
@ -120,17 +117,15 @@ class BrowseSourceScreenModel(
getRemoteManga.subscribe(sourceId, listing.query ?: "", listing.filters) getRemoteManga.subscribe(sourceId, listing.query ?: "", listing.filters)
}.flow.map { pagingData -> }.flow.map { pagingData ->
pagingData.map { pagingData.map {
withIOContext { networkToLocalManga.await(it.toDomainManga(sourceId))
networkToLocalManga.await(it.toDomainManga(sourceId)) .let { localManga ->
.let { localManga -> getManga.subscribe(localManga.url, localManga.source)
getManga.subscribe(localManga.url, localManga.source) }
} .filterNotNull()
.filterNotNull() .filter { localManga ->
.filter { localManga -> !sourcePreferences.hideInLibraryItems().get() || !localManga.favorite
!sourcePreferences.hideInLibraryItems().get() || !localManga.favorite }
} .stateIn(coroutineScope)
.stateIn(coroutineScope)
}
} }
} }
.cachedIn(coroutineScope) .cachedIn(coroutineScope)