From c07c663105cb9775a89b795916b60a9b6e7b531c Mon Sep 17 00:00:00 2001 From: FooIbar <118464521+FooIbar@users.noreply.github.com> Date: Fri, 20 Sep 2024 00:07:52 +0800 Subject: [PATCH] Address deprecation --- .../main/kotlin/com/hippo/ehviewer/coil/MergeInterceptor.kt | 6 ++++-- .../main/kotlin/com/hippo/ehviewer/util/KtorExtensions.kt | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) 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 f2fb78b4b..a6f277468 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/coil/MergeInterceptor.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/coil/MergeInterceptor.kt @@ -24,7 +24,9 @@ object MergeInterceptor : Interceptor { notifyScope.launch { synchronized(pendingContinuationMapLock) { // Wake up a pending continuation to continue executing task - val successor = pendingContinuationMap[key]?.removeFirstOrNull()?.apply { resume(Unit) { triggerSuccessor(key) } } + val successor = pendingContinuationMap[key]?.removeFirstOrNull()?.apply { + resume(Unit) { _, _, _ -> triggerSuccessor(key) } + } // If no successor, delete this entry from hashmap successor ?: pendingContinuationMap.remove(key) } @@ -48,7 +50,7 @@ object MergeInterceptor : Interceptor { val existPendingContinuations = pendingContinuationMap[key] if (existPendingContinuations == null) { pendingContinuationMap[key] = EMPTY_LIST - continuation.resume(Unit) { + continuation.resume(Unit) { _, _, _ -> triggerSuccessor(key) } } else { diff --git a/app/src/main/kotlin/com/hippo/ehviewer/util/KtorExtensions.kt b/app/src/main/kotlin/com/hippo/ehviewer/util/KtorExtensions.kt index 45b19357a..6e14cc0ee 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/util/KtorExtensions.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/util/KtorExtensions.kt @@ -5,15 +5,15 @@ import io.ktor.client.statement.HttpResponse import io.ktor.http.HttpStatusCode import io.ktor.http.isSuccess import io.ktor.utils.io.charsets.decode -import io.ktor.utils.io.core.ByteReadPacket import java.nio.charset.CodingErrorAction +import kotlinx.io.Source suspend fun HttpResponse.bodyAsUtf8Text(): String { val decoder = Charsets.UTF_8.newDecoder().apply { onMalformedInput(CodingErrorAction.REPLACE) onUnmappableCharacter(CodingErrorAction.REPLACE) } - val input = body() + val input = body() return decoder.decode(input) }