From 3edf17d322df30fa0eadaea2944f093b3456a9e6 Mon Sep 17 00:00:00 2001 From: MCAxiaz Date: Sat, 30 May 2020 06:17:27 -0700 Subject: [PATCH] handle default category and add favorite check (#3248) Download new chapters bug fix --- .../main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt index e4d4419e87..d1d1f80875 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt @@ -53,6 +53,8 @@ fun Manga.updateCoverLastModified(db: DatabaseHelper) { } fun Manga.shouldDownloadNewChapters(db: DatabaseHelper, prefs: PreferencesHelper): Boolean { + if (!favorite) return false + // Boolean to determine if user wants to automatically download new chapters. val downloadNew = prefs.downloadNew().get() if (!downloadNew) return false @@ -60,7 +62,11 @@ fun Manga.shouldDownloadNewChapters(db: DatabaseHelper, prefs: PreferencesHelper val categoriesToDownload = prefs.downloadNewCategories().get().map(String::toInt) if (categoriesToDownload.isEmpty()) return true - val categoriesForManga = db.getCategoriesForManga(this).executeAsBlocking().mapNotNull { it.id } + // Get all categories, else default category (0) + val categoriesForManga = + db.getCategoriesForManga(this).executeAsBlocking() + .mapNotNull { it.id } + .takeUnless { it.isEmpty() } ?: listOf(0) return categoriesForManga.intersect(categoriesToDownload).isNotEmpty() }