mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 04:11:48 +01:00
Replace usages of fetchChapterList with 1.x getChapterList API
This commit is contained in:
parent
4db9a90da2
commit
54dc01253d
@ -5,11 +5,14 @@ import android.net.Uri
|
|||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
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.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
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.chapter.syncChaptersWithSource
|
||||||
|
import eu.kanade.tachiyomi.util.lang.runAsObservable
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
@ -39,7 +42,10 @@ abstract class AbstractBackupManager(protected val context: Context) {
|
|||||||
* @return [Observable] that contains manga
|
* @return [Observable] that contains manga
|
||||||
*/
|
*/
|
||||||
internal fun restoreChapterFetchObservable(source: Source, manga: Manga, chapters: List<Chapter>): Observable<Pair<List<Chapter>, List<Chapter>>> {
|
internal fun restoreChapterFetchObservable(source: Source, manga: Manga, chapters: List<Chapter>): Observable<Pair<List<Chapter>, List<Chapter>>> {
|
||||||
return source.fetchChapterList(manga)
|
return runAsObservable({
|
||||||
|
source.getChapterList(manga.toMangaInfo())
|
||||||
|
.map { it.toSChapter() }
|
||||||
|
})
|
||||||
.map { syncChaptersWithSource(databaseHelper, it, manga, source) }
|
.map { syncChaptersWithSource(databaseHelper, it, manga, source) }
|
||||||
.doOnNext { (first) ->
|
.doOnNext { (first) ->
|
||||||
if (first.isNotEmpty()) {
|
if (first.isNotEmpty()) {
|
||||||
|
@ -23,6 +23,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
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.source.model.toSManga
|
||||||
import eu.kanade.tachiyomi.util.chapter.NoChaptersException
|
import eu.kanade.tachiyomi.util.chapter.NoChaptersException
|
||||||
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
||||||
@ -361,7 +362,10 @@ class LibraryUpdateService(
|
|||||||
.subscribe()
|
.subscribe()
|
||||||
}
|
}
|
||||||
|
|
||||||
return source.fetchChapterList(manga)
|
return runAsObservable({
|
||||||
|
source.getChapterList(manga.toMangaInfo())
|
||||||
|
.map { it.toSChapter() }
|
||||||
|
})
|
||||||
.map { syncChaptersWithSource(db, it, manga, source) }
|
.map { syncChaptersWithSource(db, it, manga, source) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,15 +4,18 @@ import android.os.Bundle
|
|||||||
import com.jakewharton.rxrelay.BehaviorRelay
|
import com.jakewharton.rxrelay.BehaviorRelay
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.MangaCategory
|
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.CatalogueSource
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
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.migration.MigrationFlags
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchCardItem
|
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.GlobalSearchItem
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchPresenter
|
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchPresenter
|
||||||
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
||||||
|
import eu.kanade.tachiyomi.util.lang.runAsObservable
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import rx.android.schedulers.AndroidSchedulers
|
import rx.android.schedulers.AndroidSchedulers
|
||||||
import rx.schedulers.Schedulers
|
import rx.schedulers.Schedulers
|
||||||
@ -54,7 +57,12 @@ class SearchPresenter(
|
|||||||
|
|
||||||
replacingMangaRelay.call(true)
|
replacingMangaRelay.call(true)
|
||||||
|
|
||||||
Observable.defer { source.fetchChapterList(manga) }
|
Observable.defer {
|
||||||
|
runAsObservable({
|
||||||
|
source.getChapterList(manga.toMangaInfo())
|
||||||
|
.map { it.toSChapter() }
|
||||||
|
})
|
||||||
|
}
|
||||||
.onErrorReturn { emptyList() }
|
.onErrorReturn { emptyList() }
|
||||||
.doOnNext { migrateMangaInternal(source, it, prevManga, manga, replace) }
|
.doOnNext { migrateMangaInternal(source, it, prevManga, manga, replace) }
|
||||||
.onErrorReturn { emptyList() }
|
.onErrorReturn { emptyList() }
|
||||||
|
@ -17,6 +17,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||||
import eu.kanade.tachiyomi.source.LocalSource
|
import eu.kanade.tachiyomi.source.LocalSource
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
|
import eu.kanade.tachiyomi.source.model.toSChapter
|
||||||
import eu.kanade.tachiyomi.source.model.toSManga
|
import eu.kanade.tachiyomi.source.model.toSManga
|
||||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||||
import eu.kanade.tachiyomi.ui.manga.chapter.ChapterItem
|
import eu.kanade.tachiyomi.ui.manga.chapter.ChapterItem
|
||||||
@ -160,15 +161,17 @@ class MangaPresenter(
|
|||||||
*/
|
*/
|
||||||
fun fetchMangaFromSource(manualFetch: Boolean = false) {
|
fun fetchMangaFromSource(manualFetch: Boolean = false) {
|
||||||
if (!fetchMangaSubscription.isNullOrUnsubscribed()) return
|
if (!fetchMangaSubscription.isNullOrUnsubscribed()) return
|
||||||
fetchMangaSubscription = runAsObservable({
|
fetchMangaSubscription = Observable.defer {
|
||||||
val networkManga = source.getMangaDetails(manga.toMangaInfo())
|
runAsObservable({
|
||||||
val sManga = networkManga.toSManga()
|
val networkManga = source.getMangaDetails(manga.toMangaInfo())
|
||||||
manga.prepUpdateCover(coverCache, sManga, manualFetch)
|
val sManga = networkManga.toSManga()
|
||||||
manga.copyFrom(sManga)
|
manga.prepUpdateCover(coverCache, sManga, manualFetch)
|
||||||
manga.initialized = true
|
manga.copyFrom(sManga)
|
||||||
db.insertManga(manga).executeAsBlocking()
|
manga.initialized = true
|
||||||
manga
|
db.insertManga(manga).executeAsBlocking()
|
||||||
})
|
manga
|
||||||
|
})
|
||||||
|
}
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribeFirst(
|
.subscribeFirst(
|
||||||
@ -352,7 +355,12 @@ class MangaPresenter(
|
|||||||
hasRequested = true
|
hasRequested = true
|
||||||
|
|
||||||
if (!fetchChaptersSubscription.isNullOrUnsubscribed()) return
|
if (!fetchChaptersSubscription.isNullOrUnsubscribed()) return
|
||||||
fetchChaptersSubscription = Observable.defer { source.fetchChapterList(manga) }
|
fetchChaptersSubscription = Observable.defer {
|
||||||
|
runAsObservable({
|
||||||
|
source.getChapterList(manga.toMangaInfo())
|
||||||
|
.map { it.toSChapter() }
|
||||||
|
})
|
||||||
|
}
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.map { syncChaptersWithSource(db, it, manga, source) }
|
.map { syncChaptersWithSource(db, it, manga, source) }
|
||||||
.doOnNext {
|
.doOnNext {
|
||||||
|
Loading…
Reference in New Issue
Block a user