mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 19:27:25 +01:00
Do library checks from up to 5 sources concurrently
This commit is contained in:
parent
c9035b5df9
commit
f853158e6b
@ -308,9 +308,13 @@ class LibraryUpdateService(
|
|||||||
|
|
||||||
// Emit each manga and update it sequentially.
|
// Emit each manga and update it sequentially.
|
||||||
return Observable.from(mangaToUpdate)
|
return Observable.from(mangaToUpdate)
|
||||||
|
// Update the chapters of the manga concurrently from 5 different sources
|
||||||
|
.groupBy { it.source }
|
||||||
|
.flatMap(
|
||||||
|
{ bySource ->
|
||||||
|
bySource
|
||||||
// Notify manga that will update.
|
// Notify manga that will update.
|
||||||
.doOnNext { showProgressNotification(it, count.andIncrement, mangaToUpdate.size) }
|
.doOnNext { showProgressNotification(it, count.andIncrement, mangaToUpdate.size) }
|
||||||
// Update the chapters of the manga.
|
|
||||||
.concatMap { manga ->
|
.concatMap { manga ->
|
||||||
updateManga(manga)
|
updateManga(manga)
|
||||||
// If there's any error, return empty update and continue.
|
// If there's any error, return empty update and continue.
|
||||||
@ -334,10 +338,16 @@ class LibraryUpdateService(
|
|||||||
.map {
|
.map {
|
||||||
Pair(
|
Pair(
|
||||||
manga,
|
manga,
|
||||||
(it.first.sortedByDescending { ch -> ch.source_order }.toTypedArray())
|
(
|
||||||
|
it.first.sortedByDescending { ch -> ch.source_order }
|
||||||
|
.toTypedArray()
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
5
|
||||||
|
)
|
||||||
// Add manga with new chapters to the list.
|
// Add manga with new chapters to the list.
|
||||||
.doOnNext { manga ->
|
.doOnNext { manga ->
|
||||||
// Add to the list
|
// Add to the list
|
||||||
@ -397,9 +407,13 @@ class LibraryUpdateService(
|
|||||||
|
|
||||||
// Emit each manga and update it sequentially.
|
// Emit each manga and update it sequentially.
|
||||||
return Observable.from(mangaToUpdate)
|
return Observable.from(mangaToUpdate)
|
||||||
|
// Update the details of the manga concurrently from 5 different sources
|
||||||
|
.groupBy { it.source }
|
||||||
|
.flatMap(
|
||||||
|
{ bySource ->
|
||||||
|
bySource
|
||||||
// Notify manga that will update.
|
// Notify manga that will update.
|
||||||
.doOnNext { showProgressNotification(it, count.andIncrement, mangaToUpdate.size) }
|
.doOnNext { showProgressNotification(it, count.andIncrement, mangaToUpdate.size) }
|
||||||
// Update the details of the manga.
|
|
||||||
.concatMap { manga ->
|
.concatMap { manga ->
|
||||||
val source = sourceManager.get(manga.source) as? HttpSource
|
val source = sourceManager.get(manga.source) as? HttpSource
|
||||||
?: return@concatMap Observable.empty<LibraryManga>()
|
?: return@concatMap Observable.empty<LibraryManga>()
|
||||||
@ -412,6 +426,9 @@ class LibraryUpdateService(
|
|||||||
}
|
}
|
||||||
.onErrorReturn { manga }
|
.onErrorReturn { manga }
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
5
|
||||||
|
)
|
||||||
.doOnCompleted {
|
.doOnCompleted {
|
||||||
cancelProgressNotification()
|
cancelProgressNotification()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user