diff --git a/app/src/main/kotlin/com/hippo/ehviewer/coil/MergeInterceptor.kt b/app/src/main/kotlin/com/hippo/ehviewer/coil/MergeInterceptor.kt index 3d04509f0..6c3635a56 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/coil/MergeInterceptor.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/coil/MergeInterceptor.kt @@ -34,7 +34,7 @@ suspend inline fun CancellableContinuation.evalAndResume(f: suspend () -> class TightRope : CoroutineScope, Counter by counter() { override val coroutineContext = Dispatchers.IO + Job() val actions = Channel() - val flow = actions.receiveAsFlow().map(F::invoke).buffer(0).shareIn(this, SharingStarted.WhileSubscribed()) + val flow = actions.receiveAsFlow().map(F::invoke).buffer(0).shareIn(this, SharingStarted.WhileSubscribed(stopTimeoutMillis = 200)) suspend inline fun sendAndAwait(crossinline block: suspend () -> R) = raceN( { flow.collect {} }, { suspendCancellableCoroutine { cont -> launch { actions.send { cont.evalAndResume(block) } } } },