Skip to content

Commit

Permalink
NTV-610: OperatorObserveOn.java crash due BackpressureException (#1685)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkariang committed Sep 12, 2022
1 parent 8c61ccb commit b0ffc23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import com.kickstarter.R
import com.kickstarter.databinding.FragmentBackingAddonsBinding
import com.kickstarter.libs.BaseFragment
import com.kickstarter.libs.qualifiers.RequiresFragmentViewModel
import com.kickstarter.libs.utils.ObjectUtils
import com.kickstarter.libs.utils.extensions.selectPledgeFragment
import com.kickstarter.models.Project
import com.kickstarter.models.Reward
Expand Down Expand Up @@ -85,8 +84,8 @@ class BackingAddOnsFragment : BaseFragment<BackingAddOnsFragmentViewModel.ViewMo

this.viewModel.outputs.totalSelectedAddOns()
.compose(bindToLifecycle())
.onBackpressureBuffer()
.observeOn(AndroidSchedulers.mainThread())
.filter { ObjectUtils.isNotNull(it) }
.subscribe { total ->
binding?.fragmentBackingAddonsSectionFooterLayout?.backingAddonsFooterButton ?.text = selectProperString(total)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,15 @@ class BackingAddOnsFragmentViewModel {
private fun calculateTotal(list: List<Reward>) =
this.currentSelection
.take(1)
.subscribe { map ->
.map { map ->
var total = 0
list.map { total += map[it.id()] ?: 0 }
this.totalSelectedAddOns.onNext(total)
return@map total
}
.filter { ObjectUtils.isNotNull(it) }
.compose(bindToLifecycle())
.subscribe {
this.totalSelectedAddOns.onNext(it)
}

private fun joinSelectedWithAvailableAddOns(backingList: List<Reward>, graphList: List<Reward>): List<Reward> {
Expand Down

0 comments on commit b0ffc23

Please sign in to comment.