fix block UI

pull/2048/head
821938089 2 years ago
parent 664eca08d6
commit e233acc3af
  1. 6
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt

@ -33,6 +33,8 @@ import io.legado.app.utils.postEvent
import io.legado.app.utils.toStringArray
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
/**
* 阅读界面数据处理
@ -145,10 +147,13 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
}
} else {
ReadBook.bookSource?.let {
viewModelScope.launch {
withContext(IO) {
val preUpdateJs = it.ruleToc?.preUpdateJs
if (!preUpdateJs.isNullOrBlank()) {
AnalyzeRule(book, it).evalJS(preUpdateJs)
}
}
WebBook.getChapterList(viewModelScope, it, book)
.onSuccess(IO) { cList ->
appDb.bookChapterDao.insert(*cList.toTypedArray())
@ -162,6 +167,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
}
}
}
}
/**
* 同步进度

Loading…
Cancel
Save