Skip to content

Commit 8d0a3a4

Browse files
committed
Cleanup
1 parent 6972d3e commit 8d0a3a4

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

core/src/main/java/io/snabble/sdk/Coupons.kt

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,6 @@ class Coupons (
7575
val source: LiveData<CouponSource> = MutableLiveData(CouponSource.Bundled)
7676
val isLoading: LiveData<Boolean> = MutableLiveData(false)
7777

78-
init {
79-
project.addOnUpdateListener {
80-
if (source.value == CouponSource.Bundled) {
81-
postValue(project.coupons.value)
82-
}
83-
}
84-
}
85-
8678
fun filter(type: CouponType): List<Coupon> =
8779
value?.filter { it.type == type } ?: emptyList()
8880

@@ -105,23 +97,16 @@ class Coupons (
10597
}
10698
}
10799
project.urls["coupons"]?.let { path ->
100+
val couponsUrl = Snabble.getInstance().absoluteUrl(path) ?: return
108101
isLoading.setAsap(true)
109-
val newsUrl = Snabble.getInstance().absoluteUrl(path)
110-
111-
if (newsUrl == null) {
112-
setProjectCoupons(emptyList())
113-
return
114-
}
115102

116103
val request = Request.Builder()
117-
.url(newsUrl)
104+
.url(couponsUrl)
118105
.build()
119106
val couponCall = project.okHttpClient.newCall(request)
120107
couponCall.enqueue(object : Callback {
121108
override fun onFailure(call: Call, e: IOException) {
122-
postValue(emptyList())
123109
isLoading.setAsap(false)
124-
source.setAsap(CouponSource.Online)
125110
}
126111

127112
override fun onResponse(call: Call, response: Response) {

0 commit comments

Comments
 (0)