fix: 导入在线文件bug

pull/1880/head
Xwite 3 years ago
parent a3e3901ccc
commit 7898997516
  1. 8
      app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt

@ -78,7 +78,9 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
isImportBookOnLine = (bookSource?.bookSourceType ?: BookType.local) == BookType.file isImportBookOnLine = (bookSource?.bookSourceType ?: BookType.local) == BookType.file
if (book.tocUrl.isEmpty()) { if (book.tocUrl.isEmpty()) {
loadBookInfo(book) loadBookInfo(book)
} else if (!isImportBookOnLine) { } else if (isImportBookOnLine) {
chapterListData.postValue(emptyList())
} else {
val chapterList = appDb.bookChapterDao.getChapterList(book.bookUrl) val chapterList = appDb.bookChapterDao.getChapterList(book.bookUrl)
if (chapterList.isNotEmpty()) { if (chapterList.isNotEmpty()) {
chapterListData.postValue(chapterList) chapterListData.postValue(chapterList)
@ -111,7 +113,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
execute(scope) { execute(scope) {
if (book.isLocalBook()) { if (book.isLocalBook()) {
loadChapter(book, scope) loadChapter(book, scope)
} else if (!isImportBookOnLine) { } else {
bookSource?.let { bookSource -> bookSource?.let { bookSource ->
WebBook.getBookInfo(this, bookSource, book, canReName = canReName) WebBook.getBookInfo(this, bookSource, book, canReName = canReName)
.onSuccess(IO) { .onSuccess(IO) {
@ -144,7 +146,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
appDb.bookChapterDao.insert(*it.toTypedArray()) appDb.bookChapterDao.insert(*it.toTypedArray())
chapterListData.postValue(it) chapterListData.postValue(it)
} }
} else if(!isImportBookOnLine) { } else if (isImportBookOnLine) {
chapterListData.postValue(emptyList()) chapterListData.postValue(emptyList())
} else { } else {
bookSource?.let { bookSource -> bookSource?.let { bookSource ->

Loading…
Cancel
Save