diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/AbstractBackupManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/AbstractBackupManager.kt index 1e65fe4cb..cd101484e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/AbstractBackupManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/AbstractBackupManager.kt @@ -5,11 +5,14 @@ import android.net.Uri import eu.kanade.tachiyomi.data.database.DatabaseHelper import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Manga +import eu.kanade.tachiyomi.data.database.models.toMangaInfo import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.SourceManager +import eu.kanade.tachiyomi.source.model.toSChapter import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource +import eu.kanade.tachiyomi.util.lang.runAsObservable import rx.Observable import uy.kohesive.injekt.injectLazy @@ -39,7 +42,10 @@ abstract class AbstractBackupManager(protected val context: Context) { * @return [Observable] that contains manga */ internal fun restoreChapterFetchObservable(source: Source, manga: Manga, chapters: List): Observable, List>> { - return source.fetchChapterList(manga) + return runAsObservable({ + source.getChapterList(manga.toMangaInfo()) + .map { it.toSChapter() } + }) .map { syncChaptersWithSource(databaseHelper, it, manga, source) } .doOnNext { (first) -> if (first.isNotEmpty()) { 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 469799170..adfccb11e 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 @@ -23,6 +23,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.model.SManga +import eu.kanade.tachiyomi.source.model.toSChapter import eu.kanade.tachiyomi.source.model.toSManga import eu.kanade.tachiyomi.util.chapter.NoChaptersException import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource @@ -361,7 +362,10 @@ class LibraryUpdateService( .subscribe() } - return source.fetchChapterList(manga) + return runAsObservable({ + source.getChapterList(manga.toMangaInfo()) + .map { it.toSChapter() } + }) .map { syncChaptersWithSource(db, it, manga, source) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt index bd8e4aa84..89b391fda 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt @@ -4,15 +4,18 @@ import android.os.Bundle import com.jakewharton.rxrelay.BehaviorRelay import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.MangaCategory +import eu.kanade.tachiyomi.data.database.models.toMangaInfo import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga +import eu.kanade.tachiyomi.source.model.toSChapter import eu.kanade.tachiyomi.ui.browse.migration.MigrationFlags import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchCardItem import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchItem import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchPresenter import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource +import eu.kanade.tachiyomi.util.lang.runAsObservable import rx.Observable import rx.android.schedulers.AndroidSchedulers import rx.schedulers.Schedulers @@ -54,7 +57,12 @@ class SearchPresenter( replacingMangaRelay.call(true) - Observable.defer { source.fetchChapterList(manga) } + Observable.defer { + runAsObservable({ + source.getChapterList(manga.toMangaInfo()) + .map { it.toSChapter() } + }) + } .onErrorReturn { emptyList() } .doOnNext { migrateMangaInternal(source, it, prevManga, manga, replace) } .onErrorReturn { emptyList() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt index 2556fe565..a4c75a88a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt @@ -17,6 +17,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.source.Source +import eu.kanade.tachiyomi.source.model.toSChapter import eu.kanade.tachiyomi.source.model.toSManga import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter import eu.kanade.tachiyomi.ui.manga.chapter.ChapterItem @@ -160,15 +161,17 @@ class MangaPresenter( */ fun fetchMangaFromSource(manualFetch: Boolean = false) { if (!fetchMangaSubscription.isNullOrUnsubscribed()) return - fetchMangaSubscription = runAsObservable({ - val networkManga = source.getMangaDetails(manga.toMangaInfo()) - val sManga = networkManga.toSManga() - manga.prepUpdateCover(coverCache, sManga, manualFetch) - manga.copyFrom(sManga) - manga.initialized = true - db.insertManga(manga).executeAsBlocking() - manga - }) + fetchMangaSubscription = Observable.defer { + runAsObservable({ + val networkManga = source.getMangaDetails(manga.toMangaInfo()) + val sManga = networkManga.toSManga() + manga.prepUpdateCover(coverCache, sManga, manualFetch) + manga.copyFrom(sManga) + manga.initialized = true + db.insertManga(manga).executeAsBlocking() + manga + }) + } .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribeFirst( @@ -352,7 +355,12 @@ class MangaPresenter( hasRequested = true if (!fetchChaptersSubscription.isNullOrUnsubscribed()) return - fetchChaptersSubscription = Observable.defer { source.fetchChapterList(manga) } + fetchChaptersSubscription = Observable.defer { + runAsObservable({ + source.getChapterList(manga.toMangaInfo()) + .map { it.toSChapter() } + }) + } .subscribeOn(Schedulers.io()) .map { syncChaptersWithSource(db, it, manga, source) } .doOnNext {