From 56590d9345093a49cab1d23a3a6a504e2df1b740 Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 2 Oct 2023 12:40:55 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../state/components/TokenDetailsNotification.kt | 2 -- .../factory/TokenDetailsNotificationConverter.kt | 12 +++--------- .../state/factory/TokenDetailsStateFactory.kt | 4 +--- .../tokendetails/ui/TokenDetailsScreen.kt | 2 +- .../tokendetails/viewmodels/TokenDetailsViewModel.kt | 2 +- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt index 5d7693bd08..13b31508f4 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt @@ -11,14 +11,12 @@ import com.tangem.features.tokendetails.impl.R // TODO: Finalize notification strings [REDACTED_JIRA] @Immutable sealed class TokenDetailsNotification( - open val isVisible: Boolean = true, open val config: NotificationConfig, ) { data class RentInfo( private val rentInfo: CryptoCurrencyWarning.Rent, private val onCloseClick: () -> Unit, - override val isVisible: Boolean = true, ) : TokenDetailsNotification( config = NotificationConfig( title = TextReference.Res(R.string.send_network_fee_title), diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt index 25f691722d..945fd6107e 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt @@ -1,11 +1,11 @@ package com.tangem.feature.tokendetails.presentation.tokendetails.state.factory -import com.tangem.common.extensions.cast import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsState import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.TokenDetailsNotification import com.tangem.feature.tokendetails.presentation.tokendetails.viewmodels.TokenDetailsClickIntents import com.tangem.utils.converter.Converter +import com.tangem.utils.extensions.removeBy import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.toImmutableList @@ -17,15 +17,9 @@ internal class TokenDetailsNotificationConverter( return value.map(::mapToNotification).toImmutableList() } - fun getStateRentInfoVisibility( - currentState: TokenDetailsState, - isVisible: Boolean, - ): ImmutableList { + fun removeRentInfo(currentState: TokenDetailsState): ImmutableList { val newNotifications = currentState.notifications.toMutableList() - val oldNotification = newNotifications.find { it is TokenDetailsNotification.RentInfo } - oldNotification?.let { - newNotifications.add(it.cast().copy(isVisible = isVisible)) - } + newNotifications.removeBy { it is TokenDetailsNotification.RentInfo } return newNotifications.toImmutableList() } diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt index 40f0b4da65..053b87757c 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt @@ -139,9 +139,7 @@ internal class TokenDetailsStateFactory( } fun getRefreshedState(): TokenDetailsState { - val state = currentStateProvider() return refreshStateConverter.convert(false) - .copy(notifications = notificationConverter.getStateRentInfoVisibility(state, true)) } fun getStateWithReceiveBottomSheet( @@ -212,6 +210,6 @@ internal class TokenDetailsStateFactory( fun getStateWithRemovedRentNotification(): TokenDetailsState { val state = currentStateProvider() - return state.copy(notifications = notificationConverter.getStateRentInfoVisibility(state, false)) + return state.copy(notifications = notificationConverter.removeRentInfo(state)) } } \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreen.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreen.kt index d1683f22c8..288f8e1464 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreen.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreen.kt @@ -87,7 +87,7 @@ internal fun TokenDetailsScreen(state: TokenDetailsState) { ) } items( - items = state.notifications.filter { it.isVisible }, + items = state.notifications, key = { it.config::class.java }, contentType = { it.config::class.java }, itemContent = { Notification(config = it.config, modifier = itemModifier.animateItemPlacement()) }, diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt index f37726978c..b28ca2dff7 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt @@ -365,7 +365,7 @@ internal class TokenDetailsViewModel @Inject constructor( refresh = true, ) updateTxHistory(refresh = true) - + updateWarnings(wallet) uiState = stateFactory.getRefreshedState() }.saveIn(refreshStateJobHolder) }