From 0373af42c8b008a04331201fde55f90c1450cb17 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 21 Feb 2022 15:54:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/changesource/ChangeSourceViewModel.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index 1448bdd4b..2d8a0f0b6 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -145,7 +145,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio val task = WebBook .searchBook(viewModelScope, source, name, context = searchPool!!) .timeout(60000L) - .onSuccess(searchPool) { + .onSuccess(IO) { it.forEach { searchBook -> if (searchBook.name == name) { if ((AppConfig.changeSourceCheckAuthor && searchBook.author.contains(author)) @@ -185,8 +185,8 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio } private fun loadBookInfo(source: BookSource, book: Book) { - WebBook.getBookInfo(viewModelScope, source, book) - .onSuccess { + WebBook.getBookInfo(viewModelScope, source, book, context = searchPool!!) + .onSuccess(IO) { if (context.getPrefBoolean(PreferKey.changeSourceLoadToc)) { loadBookToc(source, book) } else { @@ -195,18 +195,18 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio val searchBook = book.toSearchBook() searchCallback?.searchSuccess(searchBook) } - }.onError { + }.onError(IO) { Timber.e(it) } } private fun loadBookToc(source: BookSource, book: Book) { - WebBook.getChapterList(viewModelScope, source, book) + WebBook.getChapterList(viewModelScope, source, book, context = searchPool!!) .onSuccess(IO) { chapters -> book.latestChapterTitle = chapters.last().title val searchBook: SearchBook = book.toSearchBook() searchCallback?.searchSuccess(searchBook) - }.onError { + }.onError(IO) { Timber.e(it) } }