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 kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import uy.kohesive.injekt.injectLazy
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>> {
// Find other chains
val chainsFlow = chapters.asFlow()
.map { chapter ->
db.getChapters(chapter.url).await().mapNotNull { it.manga_id }.distinct()
val chainsFlow = flowOf(chapters)
.map { chapterList ->
chapterList.flatMap { chapter ->
db.getChapters(chapter.url).await().mapNotNull { it.manga_id }
}.distinct()
}
.map { mangaIds ->
mangaIds