Throw exceptions if some of the deprecated source methods are used

This commit is contained in:
arkon 2021-11-28 15:27:21 -05:00
parent 60e73e2d1f
commit be4f27028c
3 changed files with 17 additions and 7 deletions

View File

@ -40,23 +40,33 @@ interface Source : tachiyomi.source.Source {
* *
* @param manga the manga to update. * @param manga the manga to update.
*/ */
@Deprecated("Use getMangaDetails instead") @Deprecated(
fun fetchMangaDetails(manga: SManga): Observable<SManga> = Observable.empty() "Use the 1.x API instead",
ReplaceWith("getMangaDetails")
)
fun fetchMangaDetails(manga: SManga): Observable<SManga> = throw IllegalStateException("Not used")
/** /**
* Returns an observable with all the available chapters for a manga. * Returns an observable with all the available chapters for a manga.
* *
* @param manga the manga to update. * @param manga the manga to update.
*/ */
@Deprecated("Use getChapterList instead") @Deprecated(
fun fetchChapterList(manga: SManga): Observable<List<SChapter>> = Observable.empty() "Use the 1.x API instead",
ReplaceWith("getChapterList")
)
fun fetchChapterList(manga: SManga): Observable<List<SChapter>> = throw IllegalStateException("Not used")
// TODO: remove direct usages on this method
/** /**
* Returns an observable with the list of pages a chapter has. * Returns an observable with the list of pages a chapter has.
* *
* @param chapter the chapter. * @param chapter the chapter.
*/ */
@Deprecated("Use getPageList instead") @Deprecated(
"Use the 1.x API instead",
ReplaceWith("getPageList")
)
fun fetchPageList(chapter: SChapter): Observable<List<Page>> = Observable.empty() fun fetchPageList(chapter: SChapter): Observable<List<Page>> = Observable.empty()
/** /**

View File

@ -222,7 +222,7 @@ open class GlobalSearchPresenter(
Observable.from(first) Observable.from(first)
.filter { it.thumbnail_url == null && !it.initialized } .filter { it.thumbnail_url == null && !it.initialized }
.map { Pair(it, source) } .map { Pair(it, source) }
.concatMap { runAsObservable({ getMangaDetails(it.first, it.second) }) } .concatMap { runAsObservable { getMangaDetails(it.first, it.second) } }
.map { Pair(source as CatalogueSource, it) } .map { Pair(source as CatalogueSource, it) }
} }
.onBackpressureBuffer() .onBackpressureBuffer()

View File

@ -60,8 +60,8 @@ internal fun <T> CancellableContinuation<T>.unsubscribeOnCancellation(sub: Subsc
invokeOnCancellation { sub.unsubscribe() } invokeOnCancellation { sub.unsubscribe() }
fun <T> runAsObservable( fun <T> runAsObservable(
backpressureMode: Emitter.BackpressureMode = Emitter.BackpressureMode.NONE,
block: suspend () -> T, block: suspend () -> T,
backpressureMode: Emitter.BackpressureMode = Emitter.BackpressureMode.NONE
): Observable<T> { ): Observable<T> {
return Observable.create( return Observable.create(
{ emitter -> { emitter ->