From c2e2076b0a99cb008d3dc880ea206d4ee568b97a Mon Sep 17 00:00:00 2001 From: Carlos <2092019+CarlosEsco@users.noreply.github.com> Date: Thu, 14 May 2020 12:39:47 -0400 Subject: [PATCH] fix new chapter auto downloading when disabled (#414) * fix downloading new chapter when disabled * fix method name --- .../main/java/eu/kanade/tachiyomi/Migrations.kt | 2 +- .../tachiyomi/data/download/DownloadProvider.kt | 2 +- .../tachiyomi/ui/manga/MangaDetailsPresenter.kt | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt index 7899070d68..f739ace2af 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt @@ -67,7 +67,7 @@ object Migrations { } } if (oldVersion < 54) - DownloadProvider(context).renameChaapters() + DownloadProvider(context).renameChapters() if (oldVersion < 62) { LibraryPresenter.updateDB() // Restore jobs after migrating from Evernote's job scheduler to WorkManager. diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt index 8702bbf3e2..ab4563e153 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt @@ -109,7 +109,7 @@ class DownloadProvider(private val context: Context) { * @param manga the manga of the chapter. * @param source the source of the chapter. */ - fun renameChaapters() { + fun renameChapters() { val db by injectLazy() val sourceManager by injectLazy() val mangas = db.getLibraryMangas().executeAsBlocking() 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 d30fc46ca1..47bfb94278 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 @@ -410,13 +410,13 @@ class MangaDetailsPresenter( 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 = !controller.fromCatalogue && mangaWasInitalized - (downloadNew && (categoriesToDownload.isEmpty() || getMangaCategoryIds().any { it in categoriesToDownload })) - if (shouldDownload) { - downloadChapters(newChapters.first.sortedBy { it.chapter_number } - .map { it.toModel() }) + if (downloadNew && !controller.fromCatalogue && mangaWasInitalized) { + val categoriesToDownload = preferences.downloadNewCategories().getOrDefault().map(String::toInt) + val shouldDownload = categoriesToDownload.isEmpty() || getMangaCategoryIds().any { it in categoriesToDownload } + if (shouldDownload) { + downloadChapters(newChapters.first.sortedBy { it.chapter_number } + .map { it.toModel() }) + } } } if (newChapters.second.isNotEmpty()) {