优化进度同步逻辑,减少同步次数
This commit is contained in:
1 parent
5d55261e07
commit
c82502ee3b
9 files changed
+1992
-56
No files matched your search
@@ -204,8 +204,8 @@ object BookController {
|
||||
fun saveBook(postData: String?): ReturnData {
|
||||
val returnData = ReturnData()
|
||||
GSON.fromJsonObject<Book>(postData).getOrNull()?.let { book ->
|
||||
book.save()
|
||||
AppWebDav.uploadBookProgress(book)
|
||||
book.save()
|
||||
return returnData.setData("")
|
||||
}
|
||||
return returnData.setErrorMsg("格式不对")
|
||||
@@ -226,7 +226,7 @@ object BookController {
|
||||
/**
|
||||
* 保存进度
|
||||
*/
|
||||
fun saveBookProgress(postData: String?): ReturnData {
|
||||
suspend fun saveBookProgress(postData: String?): ReturnData {
|
||||
val returnData = ReturnData()
|
||||
GSON.fromJsonObject<BookProgress>(postData)
|
||||
.onFailure { it.printOnDebug() }
|
||||
@@ -236,8 +236,10 @@ object BookController {
|
||||
book.durChapterPos = bookProgress.durChapterPos
|
||||
book.durChapterTitle = bookProgress.durChapterTitle
|
||||
book.durChapterTime = bookProgress.durChapterTime
|
||||
AppWebDav.uploadBookProgress(bookProgress) {
|
||||
book.syncTime = System.currentTimeMillis()
|
||||
}
|
||||
appDb.bookDao.update(book)
|
||||
AppWebDav.uploadBookProgress(bookProgress)
|
||||
ReadBook.book?.let {
|
||||
if (it.name == bookProgress.name &&
|
||||
it.author == bookProgress.author
|
||||
|
||||
Reference in new issue
Block a user