Skip to content

Commit

Permalink
fix issue where add-ons were not displayed if non of the rewards were…
Browse files Browse the repository at this point in the history
… shippable (#2019) (#2020)
  • Loading branch information
mtgriego authored Apr 16, 2024
1 parent 4bb904f commit 855d5ff
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ class AddOnsViewModel(val environment: Environment) : ViewModel() {
)
shippingRules = shippingRulesEnvelope.shippingRules()
}.addToDisposable(disposables)
} ?: run {
shippingRulesObservable.onNext(listOf())
}
}
}
Expand Down Expand Up @@ -153,8 +155,12 @@ class AddOnsViewModel(val environment: Environment) : ViewModel() {
return this.currentConfig.observable()
.map { it.countryCode() }
.map { countryCode ->
shippingRules.firstOrNull { it.location()?.country() == countryCode }
?: shippingRules.first()
if (shippingRules.isNotEmpty()) {
shippingRules.firstOrNull { it.location()?.country() == countryCode }
?: shippingRules.first()
} else {
ShippingRule.builder().build()
}
}
}

Expand Down

0 comments on commit 855d5ff

Please sign in to comment.