diff options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/facebook/requests')
3 files changed, 10 insertions, 10 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() } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Images.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Images.kt index fa78bbfa..094e7fc9 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Images.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Images.kt @@ -67,7 +67,7 @@ class HdImageLoading : ModelLoader<HdImageMaybe, InputStream> { override fun buildLoadData(model: HdImageMaybe, width: Int, height: Int, - options: Options?): ModelLoader.LoadData<InputStream>? = + options: Options): ModelLoader.LoadData<InputStream>? = if (!model.isValid) null else ModelLoader.LoadData(ObjectKey(model), HdImageFetcher(model)) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Menu.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Menu.kt index 72b6e0a4..6f327662 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Menu.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Menu.kt @@ -117,7 +117,7 @@ data class MenuHeader(val id: String? = null, ) : this(id, header, visible ?: emptyList(), all ?: emptyList()) override val isValid: Boolean - get() = header != null + get() = !header.isNullOrBlank() } @JsonIgnoreProperties(ignoreUnknown = true) @@ -139,7 +139,7 @@ data class MenuItem(val id: String? = null, ) : this(id, name, pic?.formattedFbUrl, url?.formattedFbUrl, count ?: 0, countDetails) override val isValid: Boolean - get() = name != null && url != null + get() = !name.isNullOrBlank() && !url.isNullOrBlank() } data class MenuFooter(val data: List<MenuFooterItem> = emptyList(), |