diff --git a/src/main/kotlin/ca/gosyer/ui/reader/ReaderMenuViewModel.kt b/src/main/kotlin/ca/gosyer/ui/reader/ReaderMenuViewModel.kt index f196d954..01c996b6 100644 --- a/src/main/kotlin/ca/gosyer/ui/reader/ReaderMenuViewModel.kt +++ b/src/main/kotlin/ca/gosyer/ui/reader/ReaderMenuViewModel.kt @@ -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 ) } diff --git a/src/main/kotlin/ca/gosyer/ui/reader/model/ReaderChapter.kt b/src/main/kotlin/ca/gosyer/ui/reader/model/ReaderChapter.kt index 673ee569..46169122 100644 --- a/src/main/kotlin/ca/gosyer/ui/reader/model/ReaderChapter.kt +++ b/src/main/kotlin/ca/gosyer/ui/reader/model/ReaderChapter.kt @@ -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