mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-13 00:55:08 +01:00
Fix shikimori auth. Change await to withContext(Dispatchers.IO) (#354)
Co-authored-by: Pavel Mosein <p.mosein@edadeal.ru>
This commit is contained in:
parent
d20c7f41af
commit
40a0094ec0
@ -13,7 +13,6 @@ import eu.kanade.tachiyomi.data.track.TrackManager
|
|||||||
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
||||||
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 eu.kanade.tachiyomi.network.await
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import okhttp3.FormBody
|
import okhttp3.FormBody
|
||||||
@ -130,9 +129,10 @@ class ShikimoriApi(private val client: OkHttpClient, interceptor: ShikimoriInter
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getCurrentUser(): Int {
|
suspend fun getCurrentUser(): Int {
|
||||||
val response = authClient.newCall(GET("$apiUrl/users/whoami")).await()
|
return withContext(Dispatchers.IO) {
|
||||||
val user = response.body?.string()
|
val user = authClient.newCall(GET("$apiUrl/users/whoami")).execute().body?.string()
|
||||||
return JsonParser.parseString(user).obj["id"].asInt
|
JsonParser.parseString(user).obj["id"].asInt
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun accessToken(code: String): OAuth {
|
suspend fun accessToken(code: String): OAuth {
|
||||||
|
Loading…
Reference in New Issue
Block a user