Manga set to download chapters now downloads new chapters from manga details refresh

This commit is contained in:
Jay 2020-04-28 16:55:41 -04:00
parent da7adb8197
commit 931e37b903

View file

@ -411,7 +411,18 @@ class MangaDetailsPresenter(
} }
val finChapters = chapters.await() val finChapters = chapters.await()
if (finChapters.isNotEmpty()) { if (finChapters.isNotEmpty()) {
syncChaptersWithSource(db, finChapters, manga, source) val newChapters = syncChaptersWithSource(db, finChapters, manga, source)
if (newChapters.first.isNotEmpty()) {
val downloadNew = preferences.downloadNew().getOrDefault()
val categoriesToDownload =
preferences.downloadNewCategories().getOrDefault().map(String::toInt)
val shouldDownload =
(downloadNew && (categoriesToDownload.isEmpty() || getMangaCategoryIds().any { it in categoriesToDownload }))
if (shouldDownload) {
downloadChapters(newChapters.first.sortedBy { it.chapter_number }
.map { it.toModel() })
}
}
withContext(Dispatchers.IO) { updateChapters() } withContext(Dispatchers.IO) { updateChapters() }
} }
isLoading = false isLoading = false