Koharu: do not use network on main thread (#8255)
This commit is contained in:
parent
49c03653f8
commit
98bd2586fb
@ -1,7 +1,7 @@
|
|||||||
ext {
|
ext {
|
||||||
extName = 'SchaleNetwork'
|
extName = 'SchaleNetwork'
|
||||||
extClass = '.KoharuFactory'
|
extClass = '.KoharuFactory'
|
||||||
extVersionCode = 13
|
extVersionCode = 14
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.extension.all.koharu.Koharu.Companion.token
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.network.POST
|
import eu.kanade.tachiyomi.network.POST
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import okhttp3.Headers
|
import okhttp3.Headers
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
@ -120,7 +122,9 @@ class TurnstileInterceptor(
|
|||||||
try {
|
try {
|
||||||
val noRedirectClient = client.newBuilder().followRedirects(false).build()
|
val noRedirectClient = client.newBuilder().followRedirects(false).build()
|
||||||
val authHeaders = authHeaders(authHeader)
|
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 {
|
response.use {
|
||||||
if (response.isSuccessful) {
|
if (response.isSuccessful) {
|
||||||
with(response) {
|
with(response) {
|
||||||
@ -176,7 +180,9 @@ class TurnstileInterceptor(
|
|||||||
try {
|
try {
|
||||||
val noRedirectClient = client.newBuilder().followRedirects(false).build()
|
val noRedirectClient = client.newBuilder().followRedirects(false).build()
|
||||||
val authHeaders = authHeaders("Bearer $token")
|
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 {
|
response.use {
|
||||||
if (response.isSuccessful) {
|
if (response.isSuccessful) {
|
||||||
return true
|
return true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user