Updated on 2026-08-14
This commit is contained in:
parent
8d4891704c
commit
54052fe9d0
3 changed files with 29 additions and 5 deletions
|
|
@ -19,7 +19,7 @@ internal class OnrampOffersStateFactory(
|
|||
return when (currentState) {
|
||||
is OnrampV2MainComponentUM.InitialLoading -> currentState
|
||||
is OnrampV2MainComponentUM.Content -> {
|
||||
if (currentState.offersBlockState is OnrampOffersBlockUM.Loading && offers.isEmpty()) {
|
||||
if (currentState.offersBlockState is OnrampOffersBlockUM.Loading) {
|
||||
return currentState
|
||||
}
|
||||
currentState.copy(
|
||||
|
|
|
|||
|
|
@ -64,7 +64,11 @@ internal class OnrampV2AmountStateFactory(
|
|||
currencySymbol = currency.unit,
|
||||
onAmountValueChanged = onrampIntents::onAmountValueChanged,
|
||||
),
|
||||
offersBlockState = OnrampOffersBlockUM.Loading,
|
||||
offersBlockState = if (amountState.amountFieldModel.fiatValue.isEmpty()) {
|
||||
OnrampOffersBlockUM.Empty
|
||||
} else {
|
||||
OnrampOffersBlockUM.Loading
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -98,6 +102,7 @@ internal class OnrampV2AmountStateFactory(
|
|||
amountBlockState = amountState.copy(secondaryFieldModel = OnrampSecondaryFieldErrorUM.Empty),
|
||||
onrampAmountButtonUMState = OnrampV2AmountButtonUMState.None,
|
||||
errorNotification = null,
|
||||
offersBlockState = currentState.offersBlockState,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -236,8 +236,17 @@ internal class OnrampV2MainComponentModel @Inject constructor(
|
|||
maybeOffers.fold(
|
||||
ifLeft = ::handleOnrampError,
|
||||
ifRight = { offers ->
|
||||
if (offers.isNotEmpty()) {
|
||||
state.update { onrampOffersStateFactory.getOffersState(offers) }
|
||||
val currentState = state.value
|
||||
if (currentState is OnrampV2MainComponentUM.Content) {
|
||||
if (currentState.amountBlockState.amountFieldModel.fiatValue.isEmpty()) {
|
||||
state.update {
|
||||
currentState.copy(offersBlockState = OnrampOffersBlockUM.Empty)
|
||||
}
|
||||
return@fold
|
||||
}
|
||||
state.update {
|
||||
onrampOffersStateFactory.getOffersState(offers)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
@ -301,7 +310,17 @@ internal class OnrampV2MainComponentModel @Inject constructor(
|
|||
state.update { stateFactory.getErrorState(onRefresh = ::onRetryQuotes) }
|
||||
}
|
||||
else -> {
|
||||
state.update { amountStateFactory.getAmountSecondaryFieldResetState() }
|
||||
state.update { prevState ->
|
||||
val resetState = amountStateFactory.getAmountSecondaryFieldResetState()
|
||||
if (prevState is OnrampV2MainComponentUM.Content &&
|
||||
resetState is OnrampV2MainComponentUM.Content &&
|
||||
prevState.offersBlockState is OnrampOffersBlockUM.Loading
|
||||
) {
|
||||
resetState.copy(offersBlockState = OnrampOffersBlockUM.Empty)
|
||||
} else {
|
||||
resetState
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue