Updated on 2026-08-14

This commit is contained in:
Tangem 2024-05-27 16:46:13 +05:00
commit b3dc9d326d
4 changed files with 33 additions and 14 deletions

View file

@ -53,10 +53,7 @@ import com.tangem.features.send.impl.presentation.state.fee.*
import com.tangem.features.send.impl.presentation.state.recipient.RecipientSendFactory
import com.tangem.lib.crypto.BlockchainUtils
import com.tangem.utils.Provider
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import com.tangem.utils.coroutines.DelayedWork
import com.tangem.utils.coroutines.JobHolder
import com.tangem.utils.coroutines.saveIn
import com.tangem.utils.coroutines.*
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.*
@ -413,9 +410,11 @@ internal class SendViewModel @Inject constructor(
private fun getUserWallets() {
viewModelScope.launch(dispatchers.main) {
runCatching {
getWalletsUseCase.invokeSync()
?.toAvailableWallets()
.orEmpty()
waitForDelay(delay = RECENT_LOAD_DELAY) {
getWalletsUseCase.invokeSync()
?.toAvailableWallets()
.orEmpty()
}
}.onSuccess { result ->
userWallets = result
uiState = recipientStateFactory.onLoadedWalletsList(wallets = userWallets)
@ -456,10 +455,12 @@ internal class SendViewModel @Inject constructor(
}
private suspend fun getTxHistory() {
val txHistoryList = getFixedTxHistoryItemsUseCase.getSync(
userWalletId = userWalletId,
currency = cryptoCurrency,
).getOrElse { emptyList() }
val txHistoryList = waitForDelay(delay = RECENT_LOAD_DELAY) {
getFixedTxHistoryItemsUseCase.getSync(
userWalletId = userWalletId,
currency = cryptoCurrency,
).getOrElse { emptyList() }
}
uiState = recipientStateFactory.onLoadedHistoryList(txHistory = txHistoryList)
}
@ -972,6 +973,7 @@ internal class SendViewModel @Inject constructor(
private companion object {
const val CHECK_FEE_UPDATE_DELAY = 60_000L
const val BALANCE_UPDATE_DELAY = 11_000L
const val RECENT_LOAD_DELAY = 500L
const val RU_LOCALE = "ru"
const val EN_LOCALE = "en"