mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 01:31:50 +01:00
using runblocking for MAL intercept
since scope launches will run async
This commit is contained in:
parent
8ce1d94fd2
commit
06192419cb
@ -3,7 +3,7 @@ package eu.kanade.tachiyomi.data.track.myanimelist
|
|||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.runBlocking
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.RequestBody
|
import okhttp3.RequestBody
|
||||||
@ -17,14 +17,14 @@ class MyAnimeListInterceptor(private val myanimelist: MyAnimeList) : Interceptor
|
|||||||
val scope = CoroutineScope(Job() + Dispatchers.Main)
|
val scope = CoroutineScope(Job() + Dispatchers.Main)
|
||||||
|
|
||||||
override fun intercept(chain: Interceptor.Chain): Response {
|
override fun intercept(chain: Interceptor.Chain): Response {
|
||||||
scope.launch {
|
runBlocking {
|
||||||
myanimelist.ensureLoggedIn()
|
myanimelist.ensureLoggedIn()
|
||||||
}
|
}
|
||||||
val request = chain.request()
|
val request = chain.request()
|
||||||
var response = chain.proceed(updateRequest(request))
|
var response = chain.proceed(updateRequest(request))
|
||||||
|
|
||||||
if (response.code == 400) {
|
if (response.code == 400) {
|
||||||
scope.launch {
|
runBlocking {
|
||||||
myanimelist.refreshLogin()
|
myanimelist.refreshLogin()
|
||||||
}
|
}
|
||||||
response.close()
|
response.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user