mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2026-01-06 11:52:32 +01:00
Use proper coroutine context for ReaderChapter
This commit is contained in:
@@ -115,7 +115,6 @@ class ReaderMenuViewModel @Inject constructor(
|
||||
suspend fun init(mangaId: Long, chapterIndex: Int) {
|
||||
resetValues()
|
||||
val chapter = ReaderChapter(
|
||||
scope.coroutineContext + Dispatchers.Default,
|
||||
try {
|
||||
chapterHandler.getChapter(mangaId, chapterIndex)
|
||||
} catch (e: Exception) {
|
||||
@@ -136,14 +135,12 @@ class ReaderMenuViewModel @Inject constructor(
|
||||
val nextChapter = chapters.find { it.index == chapterIndex + 1 }
|
||||
if (nextChapter != null) {
|
||||
viewerChapters.nextChapter.value = ReaderChapter(
|
||||
scope.coroutineContext + Dispatchers.Default,
|
||||
nextChapter
|
||||
)
|
||||
}
|
||||
val prevChapter = chapters.find { it.index == chapterIndex - 1 }
|
||||
if (prevChapter != null) {
|
||||
viewerChapters.prevChapter.value = ReaderChapter(
|
||||
scope.coroutineContext + Dispatchers.Default,
|
||||
prevChapter
|
||||
)
|
||||
}
|
||||
|
||||
@@ -10,16 +10,15 @@ import ca.gosyer.data.models.Chapter
|
||||
import ca.gosyer.ui.reader.loader.PageLoader
|
||||
import ca.gosyer.util.system.CKLogger
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
data class ReaderChapter(val context: CoroutineContext, val chapter: Chapter) {
|
||||
var scope = CoroutineScope(context + Job())
|
||||
private set
|
||||
data class ReaderChapter(val chapter: Chapter) {
|
||||
val scope = CoroutineScope(Dispatchers.Default + Job())
|
||||
|
||||
var state: State =
|
||||
State.Wait
|
||||
|
||||
Reference in New Issue
Block a user