aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt14
1 files changed, 7 insertions, 7 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 3ca37bb4..45545336 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
@@ -21,6 +21,7 @@ private class RxAuth : RxFlyweight<String, Long, RequestAuth>() {
System.currentTimeMillis() - cond < 3600000 // valid for an hour
override fun cache(input: String) = System.currentTimeMillis()
+
}
private val auth = RxAuth()
@@ -32,13 +33,12 @@ private val auth = RxAuth()
*/
fun String?.fbRequest(fail: () -> Unit = {}, action: RequestAuth.() -> Unit) {
if (this == null) return fail()
- auth(this).subscribe { a: RequestAuth?, _ ->
- if (a?.isValid == true)
- a.action()
- else {
- L.e { "Failed auth for ${hashCode()}" }
- fail()
- }
+ try {
+ val auth = auth(this).blockingGet()
+ auth.action()
+ } catch (e: Exception) {
+ L.e { "Failed auth for ${hashCode()}: ${e.message}" }
+ fail()
}
}