[修复] 某些情况下,发现没有数据的问题
This commit is contained in:
@@ -5,8 +5,10 @@ import io.legado.app.data.entities.BookSource
|
||||
import io.legado.app.data.entities.SearchBook
|
||||
import io.legado.app.help.book.isNotShelf
|
||||
import io.legado.app.model.webBook.WebBook
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
interface ExploreRepository {
|
||||
fun getBookshelfItems(): Flow<List<SearchBook>>
|
||||
@@ -31,11 +33,14 @@ class ExploreRepositoryImpl(
|
||||
}
|
||||
|
||||
override suspend fun exploreBook(source: BookSource, url: String, page: Int): Result<List<SearchBook>> {
|
||||
return try {
|
||||
val books = WebBook.exploreBookSuspend(source, url, page)
|
||||
Result.success(books)
|
||||
} catch (e: Exception) {
|
||||
Result.failure(e)
|
||||
return withContext(Dispatchers.IO) {
|
||||
try {
|
||||
val books = WebBook.exploreBookSuspend(source, url, page)
|
||||
Result.success(books)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
Result.failure(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user