diff --git a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/states/TokenItemState.kt b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/states/TokenItemState.kt index 790a83fb5f..a5f9c615fd 100644 --- a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/states/TokenItemState.kt +++ b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/states/TokenItemState.kt @@ -25,6 +25,9 @@ sealed interface TokenItemState { /** List of networks */ val networks: ImmutableList + /** Token composed id that unique for tokens in different networks */ + val composedId: String + /** * Token item state that is available for read * @@ -32,12 +35,14 @@ sealed interface TokenItemState { * @property fullName token name * @property iconUrl token icon url * @property networks list of networks that is available for read + * @property composedId token composed id to use in lists */ data class ReadContent( override val id: String, override val fullName: String, override val iconUrl: String, override val networks: ImmutableList, + override val composedId: String, ) : TokenItemState /** @@ -47,6 +52,7 @@ sealed interface TokenItemState { * @property fullName token name * @property iconUrl token icon url * @property networks list of networks is available for read and edit + * @property composedId token composed id to use in lists * @property name token name * @property symbol token brief name */ @@ -55,6 +61,7 @@ sealed interface TokenItemState { override val fullName: String, override val iconUrl: String, override val networks: ImmutableList, + override val composedId: String, val name: String, val symbol: String, ) : TokenItemState diff --git a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokenListPreviewData.kt b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokenListPreviewData.kt index addc7020c9..819e5e4fb7 100644 --- a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokenListPreviewData.kt +++ b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokenListPreviewData.kt @@ -18,6 +18,7 @@ object TokenListPreviewData { fullName = "Tether (USDT)", iconUrl = "https://s3.eu-central-1.amazonaws.com/tangem.api/coins/large/tether.png", networks = createManageNetworksList(), + composedId = "11231", id = "", name = "Tether", symbol = "", @@ -30,6 +31,7 @@ object TokenListPreviewData { fullName = "Tether (USDT)", iconUrl = "https://s3.eu-central-1.amazonaws.com/tangem.api/coins/large/tether.png", networks = createReadNetworksList(), + composedId = "11231", ) } diff --git a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokensListScreen.kt b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokensListScreen.kt index 6896480058..b35bcd93bc 100644 --- a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokensListScreen.kt +++ b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/ui/TokensListScreen.kt @@ -134,7 +134,7 @@ private fun TokensListContent( item { DifferentAddressesWarning() } } - items(items = tokens, key = TokenItemState::id) { + items(items = tokens, key = TokenItemState::composedId) { it?.let { TokenItem(model = it) } } } diff --git a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/viewmodels/TokensListViewModel.kt b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/viewmodels/TokensListViewModel.kt index 93d386871e..c9ab947187 100644 --- a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/viewmodels/TokensListViewModel.kt +++ b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/viewmodels/TokensListViewModel.kt @@ -131,10 +131,12 @@ internal class TokensListViewModel @Inject constructor( } private fun createManageTokenContent(token: Token): TokenItemState.ManageContent { + val currentTime = System.nanoTime() return TokenItemState.ManageContent( fullName = getTokenFullName(token), iconUrl = token.iconUrl, networks = token.networks.map(::createManageNetworkContent).toImmutableList(), + composedId = token.id + currentTime, id = token.id, name = token.name, symbol = token.symbol, @@ -162,11 +164,13 @@ internal class TokensListViewModel @Inject constructor( } private fun createReadTokenContent(token: Token): TokenItemState.ReadContent { + val currentTime = System.nanoTime() return TokenItemState.ReadContent( id = token.id, fullName = getTokenFullName(token), iconUrl = token.iconUrl, networks = token.networks.map(::createReadNetworkContent).toImmutableList(), + composedId = token.id + currentTime, ) }