From 7d85262ada198501d2d5844e1196c9b45f4a38f5 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Wed, 26 Dec 2018 18:37:47 -0500 Subject: Support old fbRequest --- .../main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt index 0692fbfd..50da367d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt @@ -29,6 +29,7 @@ import com.pitchedapps.frost.utils.L import io.reactivex.Single import io.reactivex.schedulers.Schedulers import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.runBlocking import okhttp3.Call import okhttp3.FormBody import okhttp3.OkHttpClient @@ -39,7 +40,7 @@ import org.apache.commons.text.StringEscapeUtils /** * Created by Allan Wang on 21/12/17. */ - val fbAuth = Flyweight(GlobalScope, 100,3600000 /* an hour */) { +val fbAuth = Flyweight(GlobalScope, 100, 3600000 /* an hour */) { it.getAuth() } @@ -51,7 +52,7 @@ import org.apache.commons.text.StringEscapeUtils fun String?.fbRequest(fail: () -> Unit = {}, action: RequestAuth.() -> Unit) { if (this == null) return fail() try { - val auth = fbAuth(this).blockingGet() + val auth = runBlocking { fbAuth.fetch(this@fbRequest) } auth.action() } catch (e: Exception) { L.e { "Failed auth for ${hashCode()}: ${e.message}" } -- cgit v1.2.3