From bbbc8e9f48d3a14d68904f972a38c07a74414b5a Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 16 May 2022 09:58:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/api/controller/BookController.kt | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/io/legado/app/api/controller/BookController.kt b/app/src/main/java/io/legado/app/api/controller/BookController.kt index a4571bd74..c7fabb82d 100644 --- a/app/src/main/java/io/legado/app/api/controller/BookController.kt +++ b/app/src/main/java/io/legado/app/api/controller/BookController.kt @@ -215,19 +215,22 @@ object BookController { */ fun saveBookProgress(postData: String?): ReturnData { val returnData = ReturnData() - GSON.fromJsonObject(postData).getOrNull()?.let { bookProgress -> - appDb.bookDao.getBook(bookProgress.name, bookProgress.author)?.let { book -> - book.durChapterIndex = bookProgress.durChapterIndex - book.durChapterPos = bookProgress.durChapterPos - appDb.bookDao.update(book) - AppWebDav.uploadBookProgress(bookProgress) - if (ReadBook.book?.bookUrl == book.bookUrl) { - ReadBook.book = book - ReadBook.durChapterIndex = book.durChapterIndex + GSON.fromJsonObject(postData) + .onFailure { it.printOnDebug() } + .getOrNull()?.let { bookProgress -> + appDb.bookDao.getBook(bookProgress.name, bookProgress.author)?.let { book -> + book.durChapterIndex = bookProgress.durChapterIndex + book.durChapterPos = bookProgress.durChapterPos + book.durChapterTitle = bookProgress.durChapterTitle + appDb.bookDao.update(book) + AppWebDav.uploadBookProgress(bookProgress) + if (ReadBook.book?.bookUrl == book.bookUrl) { + ReadBook.book = book + ReadBook.durChapterIndex = book.durChapterIndex + } + return returnData.setData("") } - return returnData.setData("") } - } return returnData.setErrorMsg("格式不对") } @@ -241,7 +244,7 @@ object BookController { val fileData = parameters["fileData"]?.firstOrNull() ?: return returnData.setErrorMsg("fileData 不能为空") kotlin.runCatching { - LocalBook.importFileOnLine(fileData, fileName) + LocalBook.importFileOnLine(fileData, fileName) }.onFailure { return when (it) { is SecurityException -> returnData.setErrorMsg("需重新设置书籍保存位置!")