Updated on 2026-08-14

This commit is contained in:
Tangem 2024-05-28 13:18:35 +05:00
parent f540156e3d
commit 7457d4de1a
7 changed files with 71 additions and 5 deletions

View file

@ -4,7 +4,6 @@ import android.os.SystemClock
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.util.fastDistinctBy
import androidx.lifecycle.*
import arrow.core.Either
import arrow.core.getOrElse
@ -442,7 +441,7 @@ internal class SendViewModel @Inject constructor(
getNetworkAddressesUseCase.invokeSync(wallet.walletId, cryptoCurrency.network)
}
addresses
?.filter { it.address != currentAddress }
?.filter { it.address != currentAddress && it.cryptoCurrency is CryptoCurrency.Coin }
?.map { (cryptoCurrency, address) ->
AvailableWallet(
name = wallet.name,
@ -450,7 +449,7 @@ internal class SendViewModel @Inject constructor(
cryptoCurrency = cryptoCurrency,
userWalletId = wallet.walletId,
)
}?.fastDistinctBy { it.address }
}
}.flatten()
}
@ -898,10 +897,14 @@ internal class SendViewModel @Inject constructor(
val recipientState = uiState.getRecipientState(stateRouter.isEditState) ?: return
val destinationAddress = recipientState.addressTextField.value
val maybeUserWallet = userWallets.firstOrNull { it.address == destinationAddress } ?: return
val receivingUserWallet = userWallets.firstOrNull { it.address == destinationAddress } ?: return
viewModelScope.launch(dispatchers.io) {
addCryptoCurrenciesUseCase(userWalletId = maybeUserWallet.userWalletId, currency = cryptoCurrency)
addCryptoCurrenciesUseCase(
userWalletId = receivingUserWallet.userWalletId,
cryptoCurrency = cryptoCurrency,
network = receivingUserWallet.cryptoCurrency.network,
)
}
}