Koharu: do not use network on main thread (#8255)

This commit is contained in:
Vetle Ledaal 2025-03-29 08:13:57 +01:00 committed by Draff
parent 49c03653f8
commit 98bd2586fb
Signed by: Draff
GPG Key ID: E8A89F3211677653
2 changed files with 9 additions and 3 deletions

View File

@ -1,7 +1,7 @@
ext {
extName = 'SchaleNetwork'
extClass = '.KoharuFactory'
extVersionCode = 13
extVersionCode = 14
isNsfw = true
}

View File

@ -12,6 +12,8 @@ import eu.kanade.tachiyomi.extension.all.koharu.Koharu.Companion.authorization
import eu.kanade.tachiyomi.extension.all.koharu.Koharu.Companion.token
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.POST
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import okhttp3.Headers
import okhttp3.Interceptor
import okhttp3.OkHttpClient
@ -120,7 +122,9 @@ class TurnstileInterceptor(
try {
val noRedirectClient = client.newBuilder().followRedirects(false).build()
val authHeaders = authHeaders(authHeader)
val response = noRedirectClient.newCall(POST(authUrl, authHeaders)).execute()
val response = runBlocking(Dispatchers.IO) {
noRedirectClient.newCall(POST(authUrl, authHeaders)).execute()
}
response.use {
if (response.isSuccessful) {
with(response) {
@ -176,7 +180,9 @@ class TurnstileInterceptor(
try {
val noRedirectClient = client.newBuilder().followRedirects(false).build()
val authHeaders = authHeaders("Bearer $token")
val response = noRedirectClient.newCall(GET(authUrl, authHeaders)).execute()
val response = runBlocking(Dispatchers.IO) {
noRedirectClient.newCall(GET(authUrl, authHeaders)).execute()
}
response.use {
if (response.isSuccessful) {
return true