添加更新失败分组

pull/2437/head
kunfei 2 years ago
parent 7c29f4cdaf
commit 9311d7aeb9
  1. 2
      app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt
  2. 3
      app/src/main/java/io/legado/app/ui/book/manage/BookshelfManageViewModel.kt
  3. 3
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt

@ -18,6 +18,7 @@ import io.legado.app.exception.NoStackTraceException
import io.legado.app.help.book.BookHelp import io.legado.app.help.book.BookHelp
import io.legado.app.help.book.getRemoteUrl import io.legado.app.help.book.getRemoteUrl
import io.legado.app.help.book.isLocal import io.legado.app.help.book.isLocal
import io.legado.app.help.book.removeType
import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.coroutine.Coroutine
import io.legado.app.lib.webdav.ObjectNotFoundException import io.legado.app.lib.webdav.ObjectNotFoundException
import io.legado.app.model.BookCover import io.legado.app.model.BookCover
@ -236,6 +237,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
bookSource = source bookSource = source
bookData.value?.changeTo(book, toc) bookData.value?.changeTo(book, toc)
if (inBookshelf) { if (inBookshelf) {
book.removeType(BookType.updateError)
appDb.bookDao.insert(book) appDb.bookDao.insert(book)
appDb.bookChapterDao.insert(*toc.toTypedArray()) appDb.bookChapterDao.insert(*toc.toTypedArray())
} }

@ -3,10 +3,12 @@ package io.legado.app.ui.book.manage
import android.app.Application import android.app.Application
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import io.legado.app.base.BaseViewModel import io.legado.app.base.BaseViewModel
import io.legado.app.constant.BookType
import io.legado.app.data.appDb import io.legado.app.data.appDb
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.help.book.isLocal import io.legado.app.help.book.isLocal
import io.legado.app.help.book.removeType
import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.coroutine.Coroutine
import io.legado.app.model.webBook.WebBook import io.legado.app.model.webBook.WebBook
import io.legado.app.utils.toastOnUi import io.legado.app.utils.toastOnUi
@ -58,6 +60,7 @@ class BookshelfManageViewModel(application: Application) : BaseViewModel(applica
context.toastOnUi("获取目录出错\n${it.localizedMessage}") context.toastOnUi("获取目录出错\n${it.localizedMessage}")
}.getOrNull()?.let { toc -> }.getOrNull()?.let { toc ->
book.changeTo(newBook, toc) book.changeTo(newBook, toc)
book.removeType(BookType.updateError)
appDb.bookDao.insert(newBook) appDb.bookDao.insert(newBook)
appDb.bookChapterDao.insert(*toc.toTypedArray()) appDb.bookChapterDao.insert(*toc.toTypedArray())
} }

@ -9,6 +9,7 @@ import androidx.lifecycle.viewModelScope
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseViewModel import io.legado.app.base.BaseViewModel
import io.legado.app.constant.AppLog import io.legado.app.constant.AppLog
import io.legado.app.constant.BookType
import io.legado.app.constant.EventBus import io.legado.app.constant.EventBus
import io.legado.app.data.appDb import io.legado.app.data.appDb
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
@ -19,6 +20,7 @@ import io.legado.app.help.AppWebDav
import io.legado.app.help.book.BookHelp import io.legado.app.help.book.BookHelp
import io.legado.app.help.book.ContentProcessor import io.legado.app.help.book.ContentProcessor
import io.legado.app.help.book.isLocal import io.legado.app.help.book.isLocal
import io.legado.app.help.book.removeType
import io.legado.app.help.config.AppConfig import io.legado.app.help.config.AppConfig
import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.coroutine.Coroutine
import io.legado.app.model.ReadAloud import io.legado.app.model.ReadAloud
@ -215,6 +217,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
changeSourceCoroutine = execute { changeSourceCoroutine = execute {
ReadBook.upMsg(context.getString(R.string.loading)) ReadBook.upMsg(context.getString(R.string.loading))
ReadBook.book?.changeTo(book, toc) ReadBook.book?.changeTo(book, toc)
book.removeType(BookType.updateError)
appDb.bookDao.insert(book) appDb.bookDao.insert(book)
appDb.bookChapterDao.insert(*toc.toTypedArray()) appDb.bookChapterDao.insert(*toc.toTypedArray())
ReadBook.resetData(book) ReadBook.resetData(book)

Loading…
Cancel
Save