Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
821938089 committed Jul 21, 2024
1 parent c37779a commit ac9e0af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app/src/main/java/io/legado/app/help/book/BookExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ val Book.isUpError: Boolean
val Book.isArchive: Boolean
get() = isType(BookType.archive)

val Book.isNotShelf: Boolean
get() = isType(BookType.notShelf)

val Book.archiveName: String
get() {
if (!isArchive) throw NoStackTraceException("Book is not deCompressed from archive")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import io.legado.app.help.book.BookHelp
import io.legado.app.help.book.getExportFileName
import io.legado.app.help.book.getRemoteUrl
import io.legado.app.help.book.isLocal
import io.legado.app.help.book.isNotShelf
import io.legado.app.help.book.isSameNameAuthor
import io.legado.app.help.book.isWebFile
import io.legado.app.help.book.removeType
Expand Down Expand Up @@ -57,7 +58,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
val author = intent.getStringExtra("author") ?: ""
val bookUrl = intent.getStringExtra("bookUrl") ?: ""
appDb.bookDao.getBook(name, author)?.let {
inBookshelf = true
inBookshelf = !it.isNotShelf
upBook(it)
return@execute
}
Expand Down Expand Up @@ -178,7 +179,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
WebBook.getBookInfo(scope, bookSource, book, canReName = canReName)
.onSuccess(IO) {
val dbBook = appDb.bookDao.getBook(book.name, book.author)
if (dbBook != null && dbBook.origin == book.origin) {
if (dbBook != null && !dbBook.isNotShelf && dbBook.origin == book.origin) {
/**
* book 来自搜索时,搜索的书名不存在于书架,但是加载详情后,书名更新,存在同名书籍
* 此时 book 的数据会与数据库中的不同,需要更新 #3652
Expand Down

0 comments on commit ac9e0af

Please sign in to comment.