Updated on 2026-08-14

This commit is contained in:
Tangem 2024-12-17 10:25:37 +05:00
commit ffd06f3d8d
10 changed files with 18 additions and 13 deletions

View file

@ -3,15 +3,10 @@ package com.tangem.core.deeplink.global
import com.tangem.core.deeplink.DeepLink
class BuyCurrencyDeepLink(
isOnrampFeatureEnabled: Boolean,
val onReceive: (externalTxId: String) -> Unit,
) : DeepLink {
override val uri: String = if (isOnrampFeatureEnabled) {
ONRAMP_REDIRECT_DEEPLINK
} else {
BUY_REDIRECT_DEEPLINK
}
override val uri = BUY_REDIRECT_DEEPLINK
override fun onReceive(params: Map<String, String>) {
onReceive(
@ -20,7 +15,7 @@ class BuyCurrencyDeepLink(
}
companion object {
const val ONRAMP_REDIRECT_DEEPLINK = "tangem://onramp-success?"
const val ONRAMP_REDIRECT_DEEPLINK = "https://tangem.com/success?action=dismissBrowser"
private const val BUY_REDIRECT_DEEPLINK = "tangem://redirect?action=dismissBrowser"
}
}

View file

@ -415,7 +415,7 @@ internal class DefaultOnrampRepository(
fromCurrency = currency,
toAmount = quote.toAmount.value,
toCurrencyId = cryptoCurrency.id.value,
status = OnrampStatus.Status.Expired,
status = OnrampStatus.Status.Created,
externalTxUrl = onrampDataJson.externalTxUrl,
externalTxId = onrampDataJson.externalTxId,
timestamp = DateTime.now().millis,

View file

@ -308,6 +308,7 @@ internal object TokenDetailsPreviewData {
dialogConfig = null,
pendingTxs = persistentListOf(),
expressTxs = persistentListOf(),
expressTxsToDisplay = persistentListOf(),
pullToRefreshConfig = pullToRefreshConfig,
bottomSheetConfig = null,
isBalanceHidden = false,
@ -338,6 +339,7 @@ internal object TokenDetailsPreviewData {
dialogConfig = null,
pendingTxs = persistentListOf(),
expressTxs = persistentListOf(),
expressTxsToDisplay = persistentListOf(),
pullToRefreshConfig = pullToRefreshConfig,
bottomSheetConfig = null,
isBalanceHidden = false,

View file

@ -21,6 +21,7 @@ internal data class TokenDetailsState(
val stakingBlocksState: StakingBlockUM?,
val notifications: ImmutableList<TokenDetailsNotification>,
val pendingTxs: PersistentList<TransactionState>,
val expressTxsToDisplay: PersistentList<ExpressTransactionStateUM>,
val expressTxs: PersistentList<ExpressTransactionStateUM>,
val txHistoryState: TxHistoryState,
val dialogConfig: TokenDetailsDialogConfig?,

View file

@ -67,6 +67,7 @@ internal class TokenDetailsSkeletonStateConverter(
notifications = persistentListOf(),
pendingTxs = persistentListOf(),
expressTxs = persistentListOf(),
expressTxsToDisplay = persistentListOf(),
txHistoryState = TxHistoryState.Content(
contentItems = MutableStateFlow(
value = TxHistoryState.getDefaultLoadingTransactions(clickIntents::onExploreClick),

View file

@ -98,8 +98,15 @@ internal class ExpressStatusFactory @AssistedInject constructor(
if (currentTx is ExpressTransactionStateUM.ExchangeUM && currentTx.activeStatus == ExchangeStatus.Finished) {
updateBalance(currentTx.toCryptoCurrency)
}
val expressTxsToDisplay = expressTxs.filterNot {
when (it) {
is ExpressTransactionStateUM.ExchangeUM -> false
is ExpressTransactionStateUM.OnrampUM -> it.activeStatus.isHidden
}
}.toPersistentList()
return state.copy(
expressTxs = expressTxs,
expressTxsToDisplay = expressTxsToDisplay,
bottomSheetConfig = currentTx?.let(
::updateStateWithExpressStatusBottomSheet,
) ?: config,

View file

@ -61,7 +61,7 @@ internal class OnrampStatusFactory @AssistedInject constructor(
ifRight = { onrampTxs ->
val transactions = onrampTransactionStateConverter.convertList(onrampTxs)
transactions.clearHiddenTerminal()
transactions.filterNot { it.activeStatus.isHidden }
transactions
},
ifLeft = { persistentListOf() },
)

View file

@ -178,7 +178,7 @@ internal fun TokenDetailsScreen(state: TokenDetailsState, tokenMarketBlockCompon
}
expressTransactionsItems(
expressTxs = state.expressTxs,
expressTxs = state.expressTxsToDisplay,
modifier = itemModifier,
)

View file

@ -198,7 +198,6 @@ internal class TokenDetailsViewModel @Inject constructor(
viewModel = this,
deepLinks = listOf(
BuyCurrencyDeepLink(
isOnrampFeatureEnabled = onrampFeatureToggles.isFeatureEnabled,
onReceive = ::onBuyCurrencyDeepLink,
),
),
@ -336,6 +335,7 @@ internal class TokenDetailsViewModel @Inject constructor(
expressTxStatusTaskScheduler.scheduleTask(
viewModelScope,
PeriodicTask(
isDelayFirst = false,
delay = EXPRESS_STATUS_UPDATE_DELAY,
task = {
runCatching {
@ -805,7 +805,7 @@ internal class TokenDetailsViewModel @Inject constructor(
}
override fun onExpressTransactionClick(txId: String) {
val expressTxState = internalUiState.value.expressTxs.first { it.info.txId == txId }
val expressTxState = internalUiState.value.expressTxsToDisplay.first { it.info.txId == txId }
internalUiState.value = expressStatusFactory.getStateWithExpressStatusBottomSheet(expressTxState)
}

View file

@ -65,7 +65,6 @@ internal class WalletDeepLinksHandler @Inject constructor(
if (onrampFeatureToggles.isFeatureEnabled || !userWallet.isMultiCurrency) {
add(
BuyCurrencyDeepLink(
isOnrampFeatureEnabled = onrampFeatureToggles.isFeatureEnabled,
onReceive = { externalTxId ->
scope.launch { onBuyCurrencyDeepLink(externalTxId, userWallet) }
},