Fix crashes from Exh Updater

This commit is contained in:
Jobobby04 2024-11-03 22:30:47 -05:00
parent c2e36b4c5c
commit 271f2d37bb
2 changed files with 7 additions and 7 deletions

View File

@ -54,7 +54,7 @@ class EHentaiUpdateHelper(context: Context) {
suspend fun findAcceptedRootAndDiscardOthers(
sourceId: Long,
chapters: List<Chapter>,
): Triple<ChapterChain, List<ChapterChain>, Boolean> {
): Triple<ChapterChain, List<ChapterChain>, List<Chapter>> {
// Find other chains
val chains = chapters
.flatMap { chapter ->
@ -149,7 +149,7 @@ class EHentaiUpdateHelper(context: Context) {
setMangaCategories.await(it.manga.id, newCategories)
}
Triple(newAccepted, toDiscard, new)
Triple(newAccepted, toDiscard, newChapters)
} else {
/*val notNeeded = chains.filter { it.manga.id != accepted.manga.id }
val (newChapters, new) = getChapterList(accepted, notNeeded, chainsAsChapters)
@ -158,7 +158,7 @@ class EHentaiUpdateHelper(context: Context) {
// Insert new chapters for accepted manga
db.insertChapters(newAccepted.chapters).await()*/
Triple(accepted, emptyList(), false)
Triple(accepted, emptyList(), emptyList())
}
}

View File

@ -169,13 +169,13 @@ class EHentaiUpdateWorker(private val context: Context, workerParams: WorkerPara
}
// Find accepted root and discard others
val (acceptedRoot, discardedRoots, hasNew) =
val (acceptedRoot, discardedRoots, exhNew) =
updateHelper.findAcceptedRootAndDiscardOthers(manga.source, chapters)
if ((new.isNotEmpty() && manga.id == acceptedRoot.manga.id) ||
(hasNew && updatedManga.none { it.first.id == acceptedRoot.manga.id })
) {
if (new.isNotEmpty() && manga.id == acceptedRoot.manga.id) {
updatedManga += acceptedRoot.manga to new.toTypedArray()
} else if (exhNew.isNotEmpty() && updatedManga.none { it.first.id == acceptedRoot.manga.id }) {
updatedManga += acceptedRoot.manga to exhNew.toTypedArray()
}
modifiedThisIteration += acceptedRoot.manga.id