Fix book info variable update
This commit is contained in:
@@ -129,8 +129,8 @@ interface BookDao {
|
|||||||
@get:Query("select max(`order`) from books")
|
@get:Query("select max(`order`) from books")
|
||||||
val maxOrder: Int
|
val maxOrder: Int
|
||||||
|
|
||||||
@Query("select 1 from books where bookUrl = :bookUrl")
|
@Query("select exists(select 1 from books where bookUrl = :bookUrl)")
|
||||||
fun has(bookUrl: String): Boolean?
|
fun has(bookUrl: String): Boolean
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
"""select exists(select 1 from books where type & ${BookType.local} > 0
|
"""select exists(select 1 from books where type & ${BookType.local} > 0
|
||||||
|
|||||||
@@ -364,21 +364,6 @@ data class Book(
|
|||||||
return newBook
|
return newBook
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateTo(newBook: Book): Book {
|
|
||||||
newBook.durChapterIndex = durChapterIndex
|
|
||||||
newBook.durChapterTitle = durChapterTitle
|
|
||||||
newBook.durChapterPos = durChapterPos
|
|
||||||
newBook.durChapterTime = durChapterTime
|
|
||||||
newBook.group = group
|
|
||||||
newBook.order = order
|
|
||||||
newBook.customCoverUrl = customCoverUrl
|
|
||||||
newBook.customIntro = customIntro
|
|
||||||
newBook.customTag = customTag
|
|
||||||
newBook.canUpdate = canUpdate
|
|
||||||
newBook.readConfig = readConfig
|
|
||||||
return newBook
|
|
||||||
}
|
|
||||||
|
|
||||||
fun createBookMark(): Bookmark {
|
fun createBookMark(): Bookmark {
|
||||||
return Bookmark(
|
return Bookmark(
|
||||||
bookName = name,
|
bookName = name,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import io.legado.app.exception.NoStackTraceException
|
|||||||
import io.legado.app.help.config.AppConfig
|
import io.legado.app.help.config.AppConfig
|
||||||
import io.legado.app.model.localBook.LocalBook
|
import io.legado.app.model.localBook.LocalBook
|
||||||
import io.legado.app.utils.FileDoc
|
import io.legado.app.utils.FileDoc
|
||||||
|
import io.legado.app.utils.GSON
|
||||||
import io.legado.app.utils.exists
|
import io.legado.app.utils.exists
|
||||||
import io.legado.app.utils.find
|
import io.legado.app.utils.find
|
||||||
import io.legado.app.utils.inputStream
|
import io.legado.app.utils.inputStream
|
||||||
@@ -256,6 +257,26 @@ fun Book.update() {
|
|||||||
appDb.bookDao.update(this)
|
appDb.bookDao.update(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Book.updateTo(newBook: Book): Book {
|
||||||
|
newBook.durChapterIndex = durChapterIndex
|
||||||
|
newBook.durChapterTitle = durChapterTitle
|
||||||
|
newBook.durChapterPos = durChapterPos
|
||||||
|
newBook.durChapterTime = durChapterTime
|
||||||
|
newBook.group = group
|
||||||
|
newBook.order = order
|
||||||
|
newBook.customCoverUrl = customCoverUrl
|
||||||
|
newBook.customIntro = customIntro
|
||||||
|
newBook.customTag = customTag
|
||||||
|
newBook.canUpdate = canUpdate
|
||||||
|
newBook.readConfig = readConfig
|
||||||
|
val variableMap = variableMap.toMutableMap()
|
||||||
|
variableMap.putAll(newBook.variableMap)
|
||||||
|
newBook.variableMap.clear()
|
||||||
|
newBook.variableMap.putAll(variableMap)
|
||||||
|
newBook.variable = GSON.toJson(variableMap)
|
||||||
|
return newBook
|
||||||
|
}
|
||||||
|
|
||||||
fun Book.getBookSource(): BookSource? {
|
fun Book.getBookSource(): BookSource? {
|
||||||
return appDb.bookSourceDao.getBookSource(origin)
|
return appDb.bookSourceDao.getBookSource(origin)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import io.legado.app.help.book.isSameNameAuthor
|
|||||||
import io.legado.app.help.book.isWebFile
|
import io.legado.app.help.book.isWebFile
|
||||||
import io.legado.app.help.book.removeType
|
import io.legado.app.help.book.removeType
|
||||||
import io.legado.app.help.book.simulatedTotalChapterNum
|
import io.legado.app.help.book.simulatedTotalChapterNum
|
||||||
|
import io.legado.app.help.book.updateTo
|
||||||
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.AudioPlay
|
import io.legado.app.model.AudioPlay
|
||||||
@@ -191,8 +192,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
}
|
}
|
||||||
bookData.postValue(it)
|
bookData.postValue(it)
|
||||||
if (inBookshelf) {
|
if (inBookshelf) {
|
||||||
val dbBook1 = appDb.bookDao.getBook(it.bookUrl)
|
if (!appDb.bookDao.has(it.bookUrl)) {
|
||||||
if (dbBook1 == null) {
|
|
||||||
/**
|
/**
|
||||||
* 来自搜索,同一本书,不同 bookUrl
|
* 来自搜索,同一本书,不同 bookUrl
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user