BookInfoViewModel.kt:loadChapter 应该先把旧的chapterList数据清空

This commit is contained in:
Xwite
2022-02-07 20:35:13 +08:00
parent 9faa327d99
commit 71ce2fe468
@@ -118,6 +118,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
if (book.isLocalBook()) { if (book.isLocalBook()) {
LocalBook.getChapterList(book).let { LocalBook.getChapterList(book).let {
appDb.bookDao.update(book) appDb.bookDao.update(book)
appDb.bookChapterDao.delByBook(book.bookUrl)
appDb.bookChapterDao.insert(*it.toTypedArray()) appDb.bookChapterDao.insert(*it.toTypedArray())
chapterListData.postValue(it) chapterListData.postValue(it)
} }
@@ -127,6 +128,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
.onSuccess(IO) { .onSuccess(IO) {
if (inBookshelf) { if (inBookshelf) {
appDb.bookDao.update(book) appDb.bookDao.update(book)
appDb.bookChapterDao.delByBook(book.bookUrl)
appDb.bookChapterDao.insert(*it.toTypedArray()) appDb.bookChapterDao.insert(*it.toTypedArray())
} }
if (changeDruChapterIndex == null) { if (changeDruChapterIndex == null) {