From 3f7bea8d4e2af6519605b74ee63fb2e95c6fcfd8 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 31 Mar 2022 11:42:44 +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/ui/book/read/ReadBookViewModel.kt | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index f87b2f259..80c233673 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -168,20 +168,24 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { book: Book, alertSync: ((progress: BookProgress) -> Unit)? = null ) { - if (AppWebDav.syncBookProgress) - execute { + execute { + if (AppWebDav.syncBookProgress) { AppWebDav.getBookProgress(book) - }.onSuccess { - it?.let { progress -> - if (progress.durChapterIndex < book.durChapterIndex || - (progress.durChapterIndex == book.durChapterIndex && progress.durChapterPos < book.durChapterPos) - ) { - alertSync?.invoke(progress) - } else { - ReadBook.setProgress(progress) - } - } + ?: throw NoStackTraceException("没有进度") + } else { + throw NoStackTraceException("进度同步未启用") } + }.onSuccess { progress -> + if (progress.durChapterIndex < book.durChapterIndex || + (progress.durChapterIndex == book.durChapterIndex + && progress.durChapterPos < book.durChapterPos) + ) { + alertSync?.invoke(progress) + } else { + ReadBook.setProgress(progress) + } + } + } /**