Эх сурвалжийг харах

Move reader preloading to IO scope

Maybe fixes #8440
arkon 2 жил өмнө
parent
commit
e052bdef96

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt

@@ -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) }
     }
 
     /**

+ 8 - 11
app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt

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