Updated on 2026-08-14
This commit is contained in:
parent
9743ae370e
commit
a6a5d5e145
4 changed files with 43 additions and 14 deletions
|
|
@ -17,7 +17,7 @@ internal class SwapTransactionErrorStateConverter(
|
|||
is SwapTransactionState.Error.TransactionError -> {
|
||||
when (val error = value.error) {
|
||||
is SendTransactionError.UserCancelledError -> return null
|
||||
null -> SwapAlertUM.GenericError(onDismiss)
|
||||
null -> SwapAlertUM.DefaultError(onDismiss)
|
||||
else -> TransactionErrorAlertConverter(onDismiss, onSupportClick).convert(error)
|
||||
}
|
||||
}
|
||||
|
|
@ -27,8 +27,8 @@ internal class SwapTransactionErrorStateConverter(
|
|||
onConfirmClick = { onSupportClick(value.error.code.toString()) },
|
||||
)
|
||||
}
|
||||
SwapTransactionState.Error.UnknownError -> SwapAlertUM.GenericError(onDismiss)
|
||||
is SwapTransactionState.Error.TangemPayWithdrawalError -> SwapAlertUM.GenericError(
|
||||
SwapTransactionState.Error.UnknownError -> SwapAlertUM.DefaultError(onDismiss)
|
||||
is SwapTransactionState.Error.TangemPayWithdrawalError -> SwapAlertUM.SupportError(
|
||||
onConfirmClick = { onSupportClick(value.txId) },
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ internal class SwapModel @Inject constructor(
|
|||
}
|
||||
|
||||
if (fromAccountStatus == null) {
|
||||
uiState = stateBuilder.addAlert(uiState = uiState, onDismiss = swapRouter::back)
|
||||
uiState = stateBuilder.addDefaultAlert(uiState = uiState, onDismiss = swapRouter::back)
|
||||
} else {
|
||||
fromAccountCurrencyStatus = fromAccountStatus
|
||||
toAccountCurrencyStatus = toAccountStatus
|
||||
|
|
@ -360,7 +360,7 @@ internal class SwapModel @Inject constructor(
|
|||
}
|
||||
|
||||
if (fromStatus == null) {
|
||||
uiState = stateBuilder.addAlert(uiState = uiState, onDismiss = swapRouter::back)
|
||||
uiState = stateBuilder.addDefaultAlert(uiState = uiState, onDismiss = swapRouter::back)
|
||||
} else {
|
||||
initialFromStatus = fromStatus
|
||||
initialToStatus = toStatus
|
||||
|
|
@ -1020,7 +1020,7 @@ internal class SwapModel @Inject constructor(
|
|||
val fee = getSelectedFee()
|
||||
|
||||
if (fee == null && tangemPayInput?.isWithdrawal != true) {
|
||||
makeDefaultAlert(resourceReference(R.string.swapping_fee_estimation_error_text))
|
||||
makeSupportAlert(resourceReference(R.string.swapping_fee_estimation_error_text))
|
||||
modelScope.launch {
|
||||
delay(SWAP_IN_PROGRESS_DELAY)
|
||||
startLoadingQuotesFromLastState()
|
||||
|
|
@ -1046,7 +1046,7 @@ internal class SwapModel @Inject constructor(
|
|||
when (swapTransactionState) {
|
||||
is SwapTransactionState.TxSent -> {
|
||||
if (fee == null) {
|
||||
makeDefaultAlert(resourceReference(R.string.swapping_fee_estimation_error_text))
|
||||
makeSupportAlert(resourceReference(R.string.swapping_fee_estimation_error_text))
|
||||
return@onSuccess
|
||||
}
|
||||
sendSuccessSwapEvent(
|
||||
|
|
@ -1205,7 +1205,7 @@ internal class SwapModel @Inject constructor(
|
|||
}
|
||||
val feeForPermission = when (val fee = approveDataModel.fee) {
|
||||
TxFeeState.Empty -> {
|
||||
makeDefaultAlert(resourceReference(R.string.swapping_fee_estimation_error_text))
|
||||
makeSupportAlert(resourceReference(R.string.swapping_fee_estimation_error_text))
|
||||
Timber.e("Fee should not be Empty")
|
||||
return@launch
|
||||
}
|
||||
|
|
@ -1658,11 +1658,15 @@ internal class SwapModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun makeDefaultAlert() {
|
||||
uiState = stateBuilder.addAlert(uiState)
|
||||
uiState = stateBuilder.addDefaultAlert(uiState = uiState)
|
||||
}
|
||||
|
||||
private fun makeDefaultAlert(message: TextReference) {
|
||||
uiState = stateBuilder.addAlert(uiState, message)
|
||||
private fun makeSupportAlert(message: TextReference) {
|
||||
uiState = stateBuilder.addSupportAlert(
|
||||
uiState = uiState,
|
||||
message = message,
|
||||
onSupportClick = { onFailedTxEmailClick("Fee calculation error") },
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("LongMethod", "CyclomaticComplexMethod")
|
||||
|
|
|
|||
|
|
@ -7,7 +7,16 @@ import com.tangem.core.ui.extensions.resourceReference
|
|||
|
||||
sealed class SwapAlertUM : AlertUM {
|
||||
|
||||
data class GenericError(
|
||||
data class DefaultError(
|
||||
override val onConfirmClick: (() -> Unit),
|
||||
override val message: TextReference = resourceReference(R.string.common_unknown_error),
|
||||
) : SwapAlertUM() {
|
||||
override val title: TextReference? = null
|
||||
override val confirmButtonText: TextReference =
|
||||
resourceReference(id = R.string.common_ok)
|
||||
}
|
||||
|
||||
data class SupportError(
|
||||
override val onConfirmClick: (() -> Unit),
|
||||
override val message: TextReference = resourceReference(R.string.common_unknown_error),
|
||||
) : SwapAlertUM() {
|
||||
|
|
|
|||
|
|
@ -1069,7 +1069,7 @@ internal class StateBuilder(
|
|||
)
|
||||
}
|
||||
|
||||
fun addAlert(
|
||||
fun addDefaultAlert(
|
||||
uiState: SwapStateHolder,
|
||||
message: TextReference = resourceReference(R.string.common_unknown_error),
|
||||
onDismiss: () -> Unit = { clearAlert(uiState) },
|
||||
|
|
@ -1077,7 +1077,23 @@ internal class StateBuilder(
|
|||
return uiState.copy(
|
||||
event = triggeredEvent(
|
||||
SwapEvent.ShowAlert(
|
||||
SwapAlertUM.GenericError(onDismiss, message),
|
||||
SwapAlertUM.DefaultError(onDismiss, message),
|
||||
),
|
||||
onConsume = onDismiss,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fun addSupportAlert(
|
||||
uiState: SwapStateHolder,
|
||||
message: TextReference = resourceReference(R.string.common_unknown_error),
|
||||
onDismiss: () -> Unit = { clearAlert(uiState) },
|
||||
onSupportClick: () -> Unit,
|
||||
): SwapStateHolder {
|
||||
return uiState.copy(
|
||||
event = triggeredEvent(
|
||||
SwapEvent.ShowAlert(
|
||||
SwapAlertUM.SupportError(onSupportClick, message),
|
||||
),
|
||||
onConsume = onDismiss,
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue