Updated on 2026-08-14
This commit is contained in:
parent
0f6476b1ca
commit
94b59fcbe3
4 changed files with 24 additions and 21 deletions
|
|
@ -89,19 +89,19 @@ class AdditionalFeedbackInfo {
|
|||
|
||||
fun updateOnSendError(
|
||||
walletManager: WalletManager,
|
||||
amountToSend: Amount,
|
||||
amountToSend: Amount?,
|
||||
feeAmount: Amount?,
|
||||
destinationAddress: String,
|
||||
destinationAddress: String?,
|
||||
) {
|
||||
onSendErrorWalletInfo = createEmailWalletInfo(walletManager)
|
||||
this.destinationAddress = destinationAddress
|
||||
amount = amountToSend.value?.stripZeroPlainString() ?: "0"
|
||||
this.destinationAddress = destinationAddress ?: "0"
|
||||
amount = amountToSend?.value?.stripZeroPlainString() ?: "0"
|
||||
fee = if (feeAmount != null) {
|
||||
feeAmount.value?.stripZeroPlainString() ?: "0"
|
||||
} else {
|
||||
"Unable to receive"
|
||||
}
|
||||
token = if (amountToSend.type is AmountType.Token) amountToSend.currencySymbol else ""
|
||||
token = if (amountToSend?.type is AmountType.Token) amountToSend.currencySymbol else ""
|
||||
}
|
||||
|
||||
private fun createEmailWalletInfo(walletManager: WalletManager): EmailWalletInfo {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import com.tangem.tap.scope
|
|||
import com.tangem.tap.store
|
||||
import kotlinx.coroutines.launch
|
||||
import org.rekotlin.Middleware
|
||||
import java.math.BigDecimal
|
||||
|
||||
internal object LegacyMiddleware {
|
||||
val legacyMiddleware: Middleware<AppState> = { _, _ ->
|
||||
|
|
@ -41,8 +40,8 @@ internal object LegacyMiddleware {
|
|||
)?.let { walletManager ->
|
||||
store.state.globalState.feedbackManager?.infoHolder?.updateOnSendError(
|
||||
walletManager = walletManager,
|
||||
amountToSend = action.amount.convertToAmount(action.cryptoCurrency),
|
||||
feeAmount = action.fee.convertToAmount(action.cryptoCurrency),
|
||||
amountToSend = action.amount?.convertToAmount(action.cryptoCurrency),
|
||||
feeAmount = action.fee?.convertToAmount(action.cryptoCurrency),
|
||||
destinationAddress = action.destinationAddress,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@ sealed interface LegacyAction : Action {
|
|||
data class SendEmailTransactionFailed(
|
||||
val cryptoCurrency: CryptoCurrency,
|
||||
val userWalletId: UserWalletId,
|
||||
val amount: BigDecimal,
|
||||
val fee: BigDecimal,
|
||||
val destinationAddress: String,
|
||||
val amount: BigDecimal?,
|
||||
val fee: BigDecimal?,
|
||||
val destinationAddress: String?,
|
||||
val errorMessage: String,
|
||||
) : LegacyAction
|
||||
}
|
||||
|
|
@ -541,17 +541,21 @@ internal class SendViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onFailedTxEmailClick(errorMessage: String) {
|
||||
val recipient = uiState.recipientState?.addressTextField?.value ?: return
|
||||
val feeValue = uiState.feeState?.fee?.amount?.value ?: return
|
||||
val amountValue = uiState.amountState?.amountTextField?.cryptoAmount?.value ?: return
|
||||
val recipient = uiState.recipientState?.addressTextField?.value
|
||||
val feeValue = uiState.feeState?.fee?.amount?.value
|
||||
val amountValue = uiState.amountState?.amountTextField?.cryptoAmount?.value
|
||||
|
||||
val receivingAmount = checkAndCalculateSubtractedAmount(
|
||||
isAmountSubtractAvailable = isAmountSubtractAvailable,
|
||||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
amountValue = amountValue,
|
||||
feeValue = feeValue,
|
||||
reduceAmountBy = uiState.sendState?.reduceAmountBy ?: BigDecimal.ZERO,
|
||||
)
|
||||
val receivingAmount = if (amountValue != null && feeValue != null) {
|
||||
checkAndCalculateSubtractedAmount(
|
||||
isAmountSubtractAvailable = isAmountSubtractAvailable,
|
||||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
amountValue = amountValue,
|
||||
feeValue = feeValue,
|
||||
reduceAmountBy = uiState.sendState?.reduceAmountBy ?: BigDecimal.ZERO,
|
||||
)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
reduxStateHolder.dispatch(
|
||||
LegacyAction.SendEmailTransactionFailed(
|
||||
cryptoCurrency = cryptoCurrency,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue