Updated on 2026-08-14

This commit is contained in:
Tangem 2023-09-20 11:15:22 +05:00
parent ac3676ca4b
commit 4229114bb6
4 changed files with 13 additions and 13 deletions

View file

@ -12,7 +12,7 @@ import com.tangem.features.tokendetails.impl.R
@Immutable
sealed class TokenDetailsNotification(open val config: NotificationConfig) {
data class RentInfoNotification(
data class RentInfo(
private val rentInfo: CryptoCurrencyWarning.Rent,
private val onCloseClick: () -> Unit,
) : TokenDetailsNotification(
@ -27,7 +27,7 @@ sealed class TokenDetailsNotification(open val config: NotificationConfig) {
),
)
data class ExistentialDepositNotification(
data class ExistentialDeposit(
private val existentialInfo: CryptoCurrencyWarning.ExistentialDeposit,
private val onCloseClick: () -> Unit,
) : TokenDetailsNotification(
@ -42,7 +42,7 @@ sealed class TokenDetailsNotification(open val config: NotificationConfig) {
),
)
data class NetworkFeeFeeNotification(
data class NetworkFeeFee(
private val feeInfo: CryptoCurrencyWarning.BalanceNotEnoughForFee,
private val onBuyClick: () -> Unit,
) : TokenDetailsNotification(
@ -63,13 +63,13 @@ sealed class TokenDetailsNotification(open val config: NotificationConfig) {
),
iconResId = feeInfo.currency.networkIconResId,
buttonsState = NotificationConfig.ButtonsState.SecondaryButtonConfig(
text = TextReference.Str("Buy"),
text = TextReference.Res(R.string.common_buy),
onClick = onBuyClick,
),
),
)
object NetworksUnreachableNotification : TokenDetailsNotification(
object NetworksUnreachable : TokenDetailsNotification(
config = NotificationConfig(
title = TextReference.Str("Some networks are unreachable"),
subtitle = TextReference.Str("The problem is on the crypto-network side. It will be fixed soon."),

View file

@ -38,7 +38,7 @@ internal class TokenDetailsLoadedBalanceConverter(
return state.copy(
tokenBalanceBlockState = TokenDetailsBalanceBlockState.Error(state.tokenBalanceBlockState.actionButtons),
marketPriceBlockState = MarketPriceBlockState.Error(state.marketPriceBlockState.currencyName),
notifications = persistentListOf(TokenDetailsNotification.NetworksUnreachableNotification),
notifications = persistentListOf(TokenDetailsNotification.NetworksUnreachable),
)
}

View file

@ -19,31 +19,31 @@ internal class TokenDetailsNotificationConverter(
fun removeExistentialDeposit(currentState: TokenDetailsState): ImmutableList<TokenDetailsNotification> {
val newNotifications = currentState.notifications.toMutableList()
newNotifications.removeBy { it is TokenDetailsNotification.ExistentialDepositNotification }
newNotifications.removeBy { it is TokenDetailsNotification.ExistentialDeposit }
return newNotifications.toImmutableList()
}
fun removeRentInfo(currentState: TokenDetailsState): ImmutableList<TokenDetailsNotification> {
val newNotifications = currentState.notifications.toMutableList()
newNotifications.removeBy { it is TokenDetailsNotification.RentInfoNotification }
newNotifications.removeBy { it is TokenDetailsNotification.RentInfo }
return newNotifications.toImmutableList()
}
private fun mapToNotification(warning: CryptoCurrencyWarning): TokenDetailsNotification {
return when (warning) {
is CryptoCurrencyWarning.BalanceNotEnoughForFee -> TokenDetailsNotification.NetworkFeeFeeNotification(
is CryptoCurrencyWarning.BalanceNotEnoughForFee -> TokenDetailsNotification.NetworkFeeFee(
feeInfo = warning,
onBuyClick = clickIntents::onBuyClick,
)
is CryptoCurrencyWarning.ExistentialDeposit -> TokenDetailsNotification.ExistentialDepositNotification(
is CryptoCurrencyWarning.ExistentialDeposit -> TokenDetailsNotification.ExistentialDeposit(
existentialInfo = warning,
onCloseClick = clickIntents::onCloseExistentialDepositNotification,
)
is CryptoCurrencyWarning.Rent -> TokenDetailsNotification.RentInfoNotification(
is CryptoCurrencyWarning.Rent -> TokenDetailsNotification.RentInfo(
rentInfo = warning,
onCloseClick = clickIntents::onCloseRentInfoNotification,
)
CryptoCurrencyWarning.SomeNetworksUnreachable -> TokenDetailsNotification.NetworksUnreachableNotification
CryptoCurrencyWarning.SomeNetworksUnreachable -> TokenDetailsNotification.NetworksUnreachable
}
}
}

View file

@ -129,7 +129,7 @@ internal class TokenDetailsViewModel @Inject constructor(
}
private fun updateWarnings(selectedWallet: UserWallet) {
viewModelScope.launch {
viewModelScope.launch(dispatchers.io) {
getCurrencyWarningsUseCase.invoke(
userWalletId = selectedWallet.walletId,
currency = cryptoCurrency,