diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/util/ReversibleHandle.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/util/ReversibleHandle.kt index 6095da3c1..de38ffff4 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/util/ReversibleHandle.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/util/ReversibleHandle.kt @@ -1,5 +1,6 @@ package org.koitharu.kotatsu.core.ui.util +import kotlinx.coroutines.CoroutineStart import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.launch @@ -13,7 +14,7 @@ fun interface ReversibleHandle { suspend fun reverse() } -fun ReversibleHandle.reverseAsync() = processLifecycleScope.launch(Dispatchers.Default) { +fun ReversibleHandle.reverseAsync() = processLifecycleScope.launch(Dispatchers.Default, CoroutineStart.ATOMIC) { runCatchingCancellable { withContext(NonCancellable) { reverse() diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/history/domain/HistoryUpdateUseCase.kt b/app/src/main/kotlin/org/koitharu/kotatsu/history/domain/HistoryUpdateUseCase.kt index 4f307a54f..a0af9d1a8 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/history/domain/HistoryUpdateUseCase.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/history/domain/HistoryUpdateUseCase.kt @@ -1,5 +1,6 @@ package org.koitharu.kotatsu.history.domain +import kotlinx.coroutines.CoroutineStart import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.launch @@ -30,7 +31,7 @@ class HistoryUpdateUseCase @Inject constructor( manga: Manga, readerState: ReaderState, percent: Float - ) = processLifecycleScope.launch(Dispatchers.Default) { + ) = processLifecycleScope.launch(Dispatchers.Default, CoroutineStart.ATOMIC) { runCatchingCancellable { withContext(NonCancellable) { invoke(manga, readerState, percent)