pull/32/head
kunfei 5 years ago
parent 95b93171d5
commit cc1768038e
  1. 11
      app/src/main/java/io/legado/app/ui/read/ReadViewModel.kt

@ -6,6 +6,7 @@ import io.legado.app.App
import io.legado.app.base.BaseViewModel
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookSource
import io.legado.app.model.WebBook
class ReadViewModel(application: Application) : BaseViewModel(application) {
@ -19,8 +20,14 @@ class ReadViewModel(application: Application) : BaseViewModel(application) {
book = App.db.bookDao().getBook(bookUrl)
book?.let { book ->
if (App.db.bookChapterDao().getChapterCount(bookUrl) == 0) {
bookSource = App.db.bookSourceDao().getBookSource(book.origin)
if (bookSource == null) {
App.db.bookSourceDao().getBookSource(book.origin)?.let {
WebBook(it).getChapterList(book)
.onSuccess { cList ->
cList?.let {
App.db.bookChapterDao().insert(*cList.toTypedArray())
}
}
} ?: let {
}
}

Loading…
Cancel
Save