diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrencyActionsUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrencyActionsUseCase.kt index e6981db812..78c3879acb 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrencyActionsUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrencyActionsUseCase.kt @@ -50,7 +50,9 @@ class GetCryptoCurrencyActionsUseCase( userWalletId = userWallet.walletId, ) val networkId = cryptoCurrencyStatus.currency.network.id - val requirements = walletManagersFacade.getAssetRequirements(userWallet.walletId, cryptoCurrencyStatus.currency) + val requirements = withTimeoutOrNull(REQUEST_EXCHANGE_DATA_TIMEOUT) { + walletManagersFacade.getAssetRequirements(userWallet.walletId, cryptoCurrencyStatus.currency) + } return flow { val networkFlow = if (userWallet.scanResponse.cardTypesResolver.isSingleWalletWithToken()) { operations.getNetworkCoinForSingleWalletWithTokenFlow(networkId) 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 8130b96926..9f3a1887f4 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 @@ -124,6 +124,7 @@ internal class TokenDetailsViewModel @Inject constructor( private val analyticsEventsHandler: AnalyticsEventHandler, private val vibratorHapticManager: VibratorHapticManager, private val clipboardManager: ClipboardManager, + private val getCryptoCurrencySyncUseCase: GetCryptoCurrencyStatusSyncUseCase, getUserWalletUseCase: GetUserWalletUseCase, getStakingIntegrationIdUseCase: GetStakingIntegrationIdUseCase, deepLinksRegistry: DeepLinksRegistry, @@ -223,6 +224,7 @@ internal class TokenDetailsViewModel @Inject constructor( event = TokenScreenAnalyticsEvent.DetailsScreenOpened(token = cryptoCurrency.symbol), ) updateTopBarMenu() + initButtons() updateContent() handleBalanceHiding(owner) } @@ -232,6 +234,21 @@ internal class TokenDetailsViewModel @Inject constructor( super.onCleared() } + private fun initButtons() { + // we need also init buttons before start all loading to avoid buttons blocking + viewModelScope.launch { + val currentCryptoCurrencyStatus = getCryptoCurrencySyncUseCase.invoke( + userWalletId = userWalletId, + cryptoCurrencyId = cryptoCurrency.id, + isSingleWalletWithTokens = false, + ).getOrNull() + currentCryptoCurrencyStatus?.let { + cryptoCurrencyStatus = it + updateButtons(it) + } + } + } + private fun updateContent() { subscribeOnCurrencyStatusUpdates() subscribeOnExchangeTransactionsUpdates()