Cleanup UpdatesPresenter deleteChapters
(#8273)
This commit is contained in:
parent
d0bff298b7
commit
4a244a598b
@ -254,14 +254,15 @@ class UpdatesPresenter(
|
|||||||
*/
|
*/
|
||||||
fun deleteChapters(updatesItem: List<UpdatesItem>) {
|
fun deleteChapters(updatesItem: List<UpdatesItem>) {
|
||||||
presenterScope.launchNonCancellable {
|
presenterScope.launchNonCancellable {
|
||||||
val groupedUpdates = updatesItem.groupBy { it.update.mangaId }.values
|
updatesItem
|
||||||
groupedUpdates.flatMap { updates ->
|
.groupBy { it.update.mangaId }
|
||||||
val mangaId = updates.first().update.mangaId
|
.entries
|
||||||
val manga = getManga.await(mangaId) ?: return@flatMap emptyList()
|
.forEach { (mangaId, updates) ->
|
||||||
val source = sourceManager.get(manga.source) ?: return@flatMap emptyList()
|
val manga = getManga.await(mangaId) ?: return@forEach
|
||||||
val chapters = updates.mapNotNull { getChapter.await(it.update.chapterId)?.toDbChapter() }
|
val source = sourceManager.get(manga.source) ?: return@forEach
|
||||||
downloadManager.deleteChapters(chapters, manga, source).mapNotNull { it.id }
|
val chapters = updates.mapNotNull { getChapter.await(it.update.chapterId)?.toDbChapter() }
|
||||||
}
|
downloadManager.deleteChapters(chapters, manga, source)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user