From be4f27028c8abfd5f115909bee4024160c3c3fc3 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 28 Nov 2021 15:27:21 -0500 Subject: [PATCH] Throw exceptions if some of the deprecated source methods are used --- .../java/eu/kanade/tachiyomi/source/Source.kt | 20 ++++++++++++++----- .../globalsearch/GlobalSearchPresenter.kt | 2 +- .../tachiyomi/util/lang/RxCoroutineBridge.kt | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/Source.kt b/app/src/main/java/eu/kanade/tachiyomi/source/Source.kt index b8543d334..70de5a4a7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/Source.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/Source.kt @@ -40,23 +40,33 @@ interface Source : tachiyomi.source.Source { * * @param manga the manga to update. */ - @Deprecated("Use getMangaDetails instead") - fun fetchMangaDetails(manga: SManga): Observable = Observable.empty() + @Deprecated( + "Use the 1.x API instead", + ReplaceWith("getMangaDetails") + ) + fun fetchMangaDetails(manga: SManga): Observable = throw IllegalStateException("Not used") /** * Returns an observable with all the available chapters for a manga. * * @param manga the manga to update. */ - @Deprecated("Use getChapterList instead") - fun fetchChapterList(manga: SManga): Observable> = Observable.empty() + @Deprecated( + "Use the 1.x API instead", + ReplaceWith("getChapterList") + ) + fun fetchChapterList(manga: SManga): Observable> = throw IllegalStateException("Not used") + // TODO: remove direct usages on this method /** * Returns an observable with the list of pages a chapter has. * * @param chapter the chapter. */ - @Deprecated("Use getPageList instead") + @Deprecated( + "Use the 1.x API instead", + ReplaceWith("getPageList") + ) fun fetchPageList(chapter: SChapter): Observable> = Observable.empty() /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt index 8a47af86b..ab80828d3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt @@ -222,7 +222,7 @@ open class GlobalSearchPresenter( Observable.from(first) .filter { it.thumbnail_url == null && !it.initialized } .map { Pair(it, source) } - .concatMap { runAsObservable({ getMangaDetails(it.first, it.second) }) } + .concatMap { runAsObservable { getMangaDetails(it.first, it.second) } } .map { Pair(source as CatalogueSource, it) } } .onBackpressureBuffer() diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/lang/RxCoroutineBridge.kt b/app/src/main/java/eu/kanade/tachiyomi/util/lang/RxCoroutineBridge.kt index ba35b24e5..50f6d02ff 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/lang/RxCoroutineBridge.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/lang/RxCoroutineBridge.kt @@ -60,8 +60,8 @@ internal fun CancellableContinuation.unsubscribeOnCancellation(sub: Subsc invokeOnCancellation { sub.unsubscribe() } fun runAsObservable( + backpressureMode: Emitter.BackpressureMode = Emitter.BackpressureMode.NONE, block: suspend () -> T, - backpressureMode: Emitter.BackpressureMode = Emitter.BackpressureMode.NONE ): Observable { return Observable.create( { emitter ->