pull/1744/head
kunfei 3 years ago
parent e02f253252
commit 3f7bea8d4e
  1. 28
      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 {
if (progress.durChapterIndex < book.durChapterIndex || throw NoStackTraceException("进度同步未启用")
(progress.durChapterIndex == book.durChapterIndex && progress.durChapterPos < book.durChapterPos)
) {
alertSync?.invoke(progress)
} else {
ReadBook.setProgress(progress)
}
}
} }
}.onSuccess { progress ->
if (progress.durChapterIndex < book.durChapterIndex ||
(progress.durChapterIndex == book.durChapterIndex
&& progress.durChapterPos < book.durChapterPos)
) {
alertSync?.invoke(progress)
} else {
ReadBook.setProgress(progress)
}
}
} }
/** /**

Loading…
Cancel
Save