Fixed manga autodownloading chapters if manga was not initalized before

This commit is contained in:
Jay 2020-05-06 21:03:57 -04:00
parent 8fe80a0ff9
commit c70f4025f4

View File

@ -396,6 +396,7 @@ class MangaDetailsPresenter(
} }
val networkManga = nManga.await() val networkManga = nManga.await()
val mangaWasInitalized = manga.initialized
if (networkManga != null) { if (networkManga != null) {
manga.copyFrom(networkManga) manga.copyFrom(networkManga)
manga.initialized = true manga.initialized = true
@ -412,7 +413,7 @@ class MangaDetailsPresenter(
val downloadNew = preferences.downloadNew().getOrDefault() val downloadNew = preferences.downloadNew().getOrDefault()
val categoriesToDownload = val categoriesToDownload =
preferences.downloadNewCategories().getOrDefault().map(String::toInt) preferences.downloadNewCategories().getOrDefault().map(String::toInt)
val shouldDownload = !controller.fromCatalogue && val shouldDownload = !controller.fromCatalogue && mangaWasInitalized
(downloadNew && (categoriesToDownload.isEmpty() || getMangaCategoryIds().any { it in categoriesToDownload })) (downloadNew && (categoriesToDownload.isEmpty() || getMangaCategoryIds().any { it in categoriesToDownload }))
if (shouldDownload) { if (shouldDownload) {
downloadChapters(newChapters.first.sortedBy { it.chapter_number } downloadChapters(newChapters.first.sortedBy { it.chapter_number }