Skip to content

Commit

Permalink
MBL-1737: When user has no saved cards and stripe link fails or is ca…
Browse files Browse the repository at this point in the history
…nceled there is a crash
  • Loading branch information
Arkariang authored Sep 16, 2024
1 parent a2979cd commit fdf3f19
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ private fun UpdateSelectedCardIfNewCardAdded(
storedCards: List<StoredCard>,
onOptionSelected: (StoredCard?) -> Unit
) {
if (index.value != storedCards.size) {
if (index.value != storedCards.size && storedCards.isNotEmpty()) {
onOptionSelected(storedCards.first())
index.value = storedCards.size
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ class BackingAddOnsFragment : Fragment() {
}

viewModelC.provideErrorAction { message ->
showErrorToast(context, this, message ?: getString(R.string.general_error_something_wrong))
activity?.runOnUiThread {
showErrorToast(
context,
this,
message ?: getString(R.string.general_error_something_wrong)
)
}
}

// Dispose of the Composition when the view's LifecycleOwner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,13 @@ class CrowdfundCheckoutFragment : Fragment() {
} else {
binding?.composeView?.let { view ->
context?.let {
showErrorToast(it, view, error?.message ?: getString(R.string.general_error_something_wrong))
activity?.runOnUiThread {
showErrorToast(
it,
view,
error?.message ?: getString(R.string.general_error_something_wrong)
)
}
}
}
}
Expand Down Expand Up @@ -197,15 +203,19 @@ class CrowdfundCheckoutFragment : Fragment() {
is PaymentSheetResult.Canceled -> {
binding?.composeView?.let { view ->
context?.let {
showErrorToast(it, view, getString(R.string.general_error_oops))
activity?.runOnUiThread {
showErrorToast(it, view, getString(R.string.general_error_oops))
}
}
}
}
is PaymentSheetResult.Failed -> {
binding?.composeView?.let { view ->
context?.let {
val errorMessage = paymentSheetResult.error.localizedMessage ?: getString(R.string.general_error_something_wrong)
showErrorToast(it, view, errorMessage)
activity?.runOnUiThread {
showErrorToast(it, view, errorMessage)
}
}
}
}
Expand Down

0 comments on commit fdf3f19

Please sign in to comment.