Move reader preloading to IO scope

Maybe fixes #8440

(cherry picked from commit e052bdef96)
This commit is contained in:
arkon 2023-02-12 16:14:12 -05:00
parent 0ea3ac9807
commit d61db5931e
2 changed files with 9 additions and 12 deletions

View File

@ -871,7 +871,7 @@ class ReaderActivity : BaseActivity() {
* the viewer is reaching the beginning or end of a chapter or the transition page is active.
*/
fun requestPreloadChapter(chapter: ReaderChapter) {
lifecycleScope.launch { viewModel.preloadChapter(chapter) }
lifecycleScope.launchIO { viewModel.preloadChapter(chapter) }
}
/**

View File

@ -388,21 +388,18 @@ class ReaderViewModel(
return
}
logcat { "Preloading ${chapter.chapter.url}" }
val loader = loader ?: return
withIOContext {
try {
logcat { "Preloading ${chapter.chapter.url}" }
loader.loadChapter(chapter)
} catch (e: Throwable) {
if (e is CancellationException) {
throw e
}
return@withIOContext
return
}
eventChannel.trySend(Event.ReloadViewerChapters)
}
}
/**
* Called every time a page changes on the reader. Used to mark the flag of chapters being