|
|
|
@ -120,12 +120,8 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio |
|
|
|
|
.onSuccess(IO) { |
|
|
|
|
it.forEach { searchBook -> |
|
|
|
|
if (searchBook.name == name && searchBook.author == author) { |
|
|
|
|
if (context.getPrefBoolean(PreferKey.changeSourceLoadToc)) { |
|
|
|
|
if (searchBook.tocUrl.isEmpty()) { |
|
|
|
|
loadBookInfo(searchBook.toBook()) |
|
|
|
|
} else { |
|
|
|
|
loadChapter(searchBook.toBook()) |
|
|
|
|
} |
|
|
|
|
if (searchBook.latestChapterTitle.isNullOrEmpty()) { |
|
|
|
|
loadBookInfo(searchBook.toBook()) |
|
|
|
|
} else { |
|
|
|
|
searchFinish(searchBook) |
|
|
|
|
} |
|
|
|
@ -156,7 +152,14 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio |
|
|
|
|
App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource -> |
|
|
|
|
WebBook(bookSource).getBookInfo(book, this) |
|
|
|
|
.onSuccess { |
|
|
|
|
loadChapter(it) |
|
|
|
|
if (context.getPrefBoolean(PreferKey.changeSourceLoadToc)) { |
|
|
|
|
loadChapter(it) |
|
|
|
|
} else { |
|
|
|
|
//从详情页里获取最新章节 |
|
|
|
|
book.latestChapterTitle = it.latestChapterTitle |
|
|
|
|
val searchBook = book.toSearchBook() |
|
|
|
|
searchFinish(searchBook) |
|
|
|
|
} |
|
|
|
|
}.onError { |
|
|
|
|
debug { context.getString(R.string.error_get_book_info) } |
|
|
|
|
} |
|
|
|
|