Fixed EH update helper crashes

This commit is contained in:
Jobobby04 2020-10-24 19:41:16 -04:00
parent fa7c6716f4
commit b252a9e060

View File

@ -11,6 +11,7 @@ import exh.metadata.metadata.base.getFlatMetadataForManga
import exh.util.await import exh.util.await
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.io.File import java.io.File
@ -33,9 +34,11 @@ class EHentaiUpdateHelper(context: Context) {
*/ */
fun findAcceptedRootAndDiscardOthers(sourceId: Long, chapters: List<Chapter>): Flow<Triple<ChapterChain, List<ChapterChain>, Boolean>> { fun findAcceptedRootAndDiscardOthers(sourceId: Long, chapters: List<Chapter>): Flow<Triple<ChapterChain, List<ChapterChain>, Boolean>> {
// Find other chains // Find other chains
val chainsFlow = chapters.asFlow() val chainsFlow = flowOf(chapters)
.map { chapter -> .map { chapterList ->
db.getChapters(chapter.url).await().mapNotNull { it.manga_id }.distinct() chapterList.flatMap { chapter ->
db.getChapters(chapter.url).await().mapNotNull { it.manga_id }
}.distinct()
} }
.map { mangaIds -> .map { mangaIds ->
mangaIds mangaIds