From 931e37b903ebb1345043803a994f8d17ba19db2e Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 28 Apr 2020 16:55:41 -0400 Subject: [PATCH] Manga set to download chapters now downloads new chapters from manga details refresh --- .../tachiyomi/ui/manga/MangaDetailsPresenter.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt index 63b3696ede..9d11131868 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt @@ -411,7 +411,18 @@ class MangaDetailsPresenter( } val finChapters = chapters.await() 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() } } isLoading = false