Updated on 2026-08-14

This commit is contained in:
Tangem 2025-01-31 18:24:49 +05:00
parent eadf1a17c8
commit 2f3e6db10d
8 changed files with 51 additions and 16 deletions

View file

@ -80,15 +80,19 @@ internal class TokenDetailsSwapTransactionsStateConverter(
fromFiatAmount = quote.fiatRate.multiply(fromAmount)
}
}
val notifications =
getNotification(transaction.status?.status, transaction.status?.txExternalUrl, null)
val statusModel = transaction.status
val notifications = getNotification(
status = statusModel?.status,
txUrl = statusModel?.txExternalUrl,
refundToken = statusModel?.refundCurrency,
)
val showProviderLink = getShowProviderLink(notifications, transaction.status)
result.add(
ExchangeUM(
provider = transaction.provider,
statuses = getStatuses(transaction.status?.status),
statuses = getStatuses(statusModel?.status),
notification = notifications,
activeStatus = transaction.status?.status,
activeStatus = statusModel?.status,
showProviderLink = showProviderLink,
fromCryptoCurrency = fromCryptoCurrency,
toCryptoCurrency = toCryptoCurrency,
@ -106,13 +110,13 @@ internal class TokenDetailsSwapTransactionsStateConverter(
return result.toPersistentList()
}
fun updateTxStatus(tx: ExchangeUM, statusModel: ExchangeStatusModel?, refundToken: CryptoCurrency?): ExchangeUM {
fun updateTxStatus(tx: ExchangeUM, statusModel: ExchangeStatusModel?): ExchangeUM {
if (statusModel == null || tx.activeStatus == statusModel.status) {
Timber.e("UpdateTxStatus isn't required. Current status isn't changed")
return tx
}
val hasFailed = statusModel.status == ExchangeStatus.Failed
val notifications = getNotification(statusModel.status, statusModel.txExternalUrl, refundToken)
val notifications = getNotification(statusModel.status, statusModel.txExternalUrl, statusModel.refundCurrency)
val showProviderLink = getShowProviderLink(notifications, statusModel)
return tx.copy(
activeStatus = statusModel.status,

View file

@ -101,11 +101,9 @@ internal class ExchangeStatusFactory @AssistedInject constructor(
} else {
val statusModel = getExchangeStatus(swapTx.info.txId, swapTx.provider)
val addedRefundToken = addRefundCurrencyIfNeeded(statusModel, swapTx.provider.type)
swapTransactionsStateConverter.updateTxStatus(
tx = swapTx,
statusModel = statusModel,
refundToken = addedRefundToken,
)
}
}
@ -116,8 +114,11 @@ internal class ExchangeStatusFactory @AssistedInject constructor(
ifLeft = { null },
ifRight = { statusModel ->
sendStatusUpdateAnalytics(statusModel, provider)
swapTransactionRepository.storeTransactionState(txId, statusModel)
statusModel
val refundTokenCurrency = addRefundCurrencyIfNeeded(statusModel, provider.type)
swapTransactionRepository.storeTransactionState(txId, statusModel, refundTokenCurrency)
statusModel.copy(refundCurrency = refundTokenCurrency)
},
)
}

View file

@ -784,7 +784,6 @@ internal class TokenDetailsViewModel @Inject constructor(
}
override fun onGoToRefundedTokenClick(cryptoCurrency: CryptoCurrency) {
onDisposeExpressStatus()
router.openTokenDetails(userWalletId, cryptoCurrency)
}