Move reader preloading to IO scope

Maybe fixes #8440

(cherry picked from commit e052bdef96c133b92dfad214c2b05ab03d4c5866)
This commit is contained in:
arkon 2023-02-12 16:14:12 -05:00 committed by Jobobby04
parent b42c5b58ea
commit ab8c8db6ac
2 changed files with 9 additions and 12 deletions

View File

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

View File

@ -471,20 +471,17 @@ class ReaderViewModel(
return return
} }
logcat { "Preloading ${chapter.chapter.url}" }
val loader = loader ?: return val loader = loader ?: return
withIOContext { try {
try { logcat { "Preloading ${chapter.chapter.url}" }
loader.loadChapter(chapter) loader.loadChapter(chapter)
} catch (e: Throwable) { } catch (e: Throwable) {
if (e is CancellationException) { if (e is CancellationException) {
throw e throw e
}
return@withIOContext
} }
eventChannel.trySend(Event.ReloadViewerChapters) return
} }
eventChannel.trySend(Event.ReloadViewerChapters)
} }
/** /**