Isolate EH and EXH manga redirects

This commit is contained in:
NerdNumber9 2019-08-08 14:45:40 -04:00
parent dce08d4922
commit 14879c4466
3 changed files with 6 additions and 4 deletions

View File

@ -120,7 +120,7 @@ class ChaptersPresenter(
&& DebugToggles.ENABLE_EXH_ROOT_REDIRECT.enabled) {
// Check for gallery in library and accept manga with lowest id
// Find chapters sharing same root
add(updateHelper.findAcceptedRootAndDiscardOthers(chapters)
add(updateHelper.findAcceptedRootAndDiscardOthers(manga.source, chapters)
.subscribeOn(Schedulers.io())
.subscribe { (acceptedChain, _) ->
// Redirect if we are not the accepted root

View File

@ -28,7 +28,7 @@ class EHentaiUpdateHelper(context: Context) {
*
* @return Pair<Accepted, Discarded>
*/
fun findAcceptedRootAndDiscardOthers(chapters: List<Chapter>): Single<Pair<ChapterChain, List<ChapterChain>>> {
fun findAcceptedRootAndDiscardOthers(sourceId: Long, chapters: List<Chapter>): Single<Pair<ChapterChain, List<ChapterChain>>> {
// Find other chains
val chainsObservable = Observable.merge(chapters.map { chapter ->
db.getChapters(chapter.url).asRxSingle().toObservable()
@ -42,7 +42,9 @@ class EHentaiUpdateHelper(context: Context) {
db.getChaptersByMangaId(mangaId).asRxSingle()
) { manga, chapters ->
ChapterChain(manga, chapters)
}.toObservable()
}.toObservable().filter {
it.manga.source == sourceId
}
}
)
}.toList()

View File

@ -206,7 +206,7 @@ class EHentaiUpdateWorker: JobService(), CoroutineScope {
// Find accepted root and discard others
val (acceptedRoot, discardedRoots) =
updateHelper.findAcceptedRootAndDiscardOthers(chapters).await()
updateHelper.findAcceptedRootAndDiscardOthers(manga.source, chapters).await()
modifiedThisIteration += acceptedRoot.manga.id!!
modifiedThisIteration += discardedRoots.map { it.manga.id!! }