diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt index f436fe0ef9..17fe96dbc0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt @@ -110,7 +110,6 @@ class LibraryUpdateService( */ enum class Target { CHAPTERS, // Manga chapters - DETAILS, // Manga metadata TRACKING // Tracking metadata } @@ -234,7 +233,6 @@ class LibraryUpdateService( // Update either chapter list or manga details. when (target) { Target.CHAPTERS -> updateChapterList(mangaList) - Target.DETAILS -> updateDetails(mangaList) Target.TRACKING -> updateTrackings(mangaList) } } @@ -390,50 +388,22 @@ class LibraryUpdateService( */ fun updateManga(manga: Manga): Observable, List>> { val source = sourceManager.get(manga.source) as? HttpSource ?: return Observable.empty() + + // Update manga details metadata in the background + source.fetchMangaDetails(manga) + .map { networkManga -> + manga.copyFrom(networkManga) + db.insertManga(manga).executeAsBlocking() + manga + } + .onErrorResumeNext { Observable.just(manga) } + .subscribeOn(Schedulers.io()) + .subscribe() + return source.fetchChapterList(manga) .map { syncChaptersWithSource(db, it, manga, source) } } - /** - * Method that updates the details of the given list of manga. It's called in a background - * thread, so it's safe to do heavy operations or network calls here. - * - * @param mangaToUpdate the list to update - * @return an observable delivering the progress of each update. - */ - fun updateDetails(mangaToUpdate: List): Observable { - // Initialize the variables holding the progress of the updates. - val count = AtomicInteger(0) - - // Emit each manga and update it sequentially. - return Observable.from(mangaToUpdate) - // Update the details of the manga concurrently from 5 different sources - .groupBy { it.source } - .flatMap( - { bySource -> - bySource - // Notify manga that will update. - .doOnNext { showProgressNotification(it, count.andIncrement, mangaToUpdate.size) } - .concatMap { manga -> - val source = sourceManager.get(manga.source) as? HttpSource - ?: return@concatMap Observable.empty() - - source.fetchMangaDetails(manga) - .map { networkManga -> - manga.copyFrom(networkManga) - db.insertManga(manga).executeAsBlocking() - manga - } - .onErrorReturn { manga } - } - }, - 5 - ) - .doOnCompleted { - cancelProgressNotification() - } - } - /** * Method that updates the metadata of the connected tracking services. It's called in a * background thread, so it's safe to do heavy operations or network calls here. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt index f4ffd794d5..582cd4a23d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt @@ -76,12 +76,6 @@ class SettingsAdvancedController : SettingsController() { ctrl.showDialog(router) } } - preference { - titleRes = R.string.pref_refresh_library_metadata - summaryRes = R.string.pref_refresh_library_metadata_summary - - onClick { LibraryUpdateService.start(context, target = Target.DETAILS) } - } preference { titleRes = R.string.pref_refresh_library_tracking summaryRes = R.string.pref_refresh_library_tracking_summary diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d6309d420d..e3ff0c816c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -353,9 +353,7 @@ Delete manga and chapters that are not in your library Are you sure? Read chapters and progress of non-library manga will be lost Entries deleted - Refresh library metadata - Updates covers, genres, description and manga status information - Refresh tracking metadata + Refresh tracking Updates status, score and last chapter read from the tracking services Disable battery optimization Helps with background library updates and backups