Fix shikimori auth (#280)

Co-authored-by: Pavel Mosein <p.mosein@edadeal.ru>
This commit is contained in:
Jays2Kings 2020-05-02 15:41:50 -04:00 committed by GitHub
commit e89b10374a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,7 @@ import eu.kanade.tachiyomi.data.track.TrackManager
import eu.kanade.tachiyomi.data.track.model.TrackSearch
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.POST
import eu.kanade.tachiyomi.network.await
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okhttp3.FormBody
@ -128,8 +129,9 @@ class ShikimoriApi(private val client: OkHttpClient, interceptor: ShikimoriInter
}
}
fun getCurrentUser(): Int {
val user = authClient.newCall(GET("$apiUrl/users/whoami")).execute().body?.string()
suspend fun getCurrentUser(): Int {
val response = authClient.newCall(GET("$apiUrl/users/whoami")).await()
val user = response.body?.string()
return JsonParser.parseString(user).obj["id"].asInt
}