Updated on 2026-08-14

This commit is contained in:
Tangem 2023-10-27 11:15:57 +03:00
parent fd48173296
commit c3de434c54
3 changed files with 13 additions and 9 deletions

View file

@ -29,7 +29,6 @@ internal class TokenActionsProvider(
fun provideActions(tokenActions: TokenActionsState): ImmutableList<TokenActionButtonConfig> {
return tokenActions.states
.filterIfSingleWithToken()
.filterIfS2C()
.mapNotNull {
mapTokenActionState(
actionsState = it,
@ -47,14 +46,6 @@ internal class TokenActionsProvider(
}
}
private fun List<TokenActionsState.ActionState>.filterIfS2C(): List<TokenActionsState.ActionState> {
return if (currentWalletProvider().scanResponse.cardTypesResolver.isStart2Coin()) {
filterNot { it is TokenActionsState.ActionState.Buy || it is TokenActionsState.ActionState.Sell }
} else {
this
}
}
private fun mapTokenActionState(
actionsState: TokenActionsState.ActionState,
cryptoCurrencyStatus: CryptoCurrencyStatus,

View file

@ -1,7 +1,9 @@
package com.tangem.feature.wallet.presentation.wallet.state.factory
import com.tangem.common.Provider
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.tokens.model.TokenActionsState
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.feature.wallet.presentation.wallet.state.WalletMultiCurrencyState
import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
@ -12,6 +14,7 @@ import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.toPersistentList
internal class WalletCryptoCurrencyActionsConverter(
private val currentWalletProvider: Provider<UserWallet>,
private val currentStateProvider: Provider<WalletState>,
private val clickIntents: WalletClickIntents,
) : Converter<TokenActionsState, WalletState> {
@ -28,6 +31,7 @@ internal class WalletCryptoCurrencyActionsConverter(
private fun TokenActionsState.mapToManageButtons(): PersistentList<WalletManageButton> {
return this.states
.filterIfS2C()
.mapNotNull { action ->
when (action) {
is TokenActionsState.ActionState.Buy -> {
@ -60,4 +64,12 @@ internal class WalletCryptoCurrencyActionsConverter(
}
.toPersistentList()
}
private fun List<TokenActionsState.ActionState>.filterIfS2C(): List<TokenActionsState.ActionState> {
return if (currentWalletProvider().scanResponse.cardTypesResolver.isStart2Coin()) {
filterNot { it is TokenActionsState.ActionState.Buy || it is TokenActionsState.ActionState.Sell }
} else {
this
}
}
}

View file

@ -127,6 +127,7 @@ internal class WalletStateFactory(
private val cryptoCurrencyActionsConverter by lazy {
WalletCryptoCurrencyActionsConverter(
currentWalletProvider = currentWalletProvider,
currentStateProvider = currentStateProvider,
clickIntents = clickIntents,
)