pull/1744/head
kunfei 3 years ago
parent e02f253252
commit 3f7bea8d4e
  1. 14
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt

@ -168,20 +168,24 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
book: Book, book: Book,
alertSync: ((progress: BookProgress) -> Unit)? = null alertSync: ((progress: BookProgress) -> Unit)? = null
) { ) {
if (AppWebDav.syncBookProgress)
execute { execute {
if (AppWebDav.syncBookProgress) {
AppWebDav.getBookProgress(book) AppWebDav.getBookProgress(book)
}.onSuccess { ?: throw NoStackTraceException("没有进度")
it?.let { progress -> } else {
throw NoStackTraceException("进度同步未启用")
}
}.onSuccess { progress ->
if (progress.durChapterIndex < book.durChapterIndex || if (progress.durChapterIndex < book.durChapterIndex ||
(progress.durChapterIndex == book.durChapterIndex && progress.durChapterPos < book.durChapterPos) (progress.durChapterIndex == book.durChapterIndex
&& progress.durChapterPos < book.durChapterPos)
) { ) {
alertSync?.invoke(progress) alertSync?.invoke(progress)
} else { } else {
ReadBook.setProgress(progress) ReadBook.setProgress(progress)
} }
} }
}
} }
/** /**

Loading…
Cancel
Save