Updated on 2026-08-14

This commit is contained in:
Tangem 2025-07-30 15:30:39 +04:00
parent b0b416c9c3
commit 43108b25b5

View file

@ -10,7 +10,9 @@ import com.tangem.domain.wallets.repository.WalletsRepository
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.withContext
import kotlinx.coroutines.withTimeoutOrNull
import javax.inject.Inject
import kotlin.time.Duration.Companion.seconds
class UserTokensResponseAddressesEnricher @Inject constructor(
private val notificationsFeatureToggles: NotificationsFeatureToggles,
@ -28,7 +30,10 @@ class UserTokensResponseAddressesEnricher @Inject constructor(
return withContext(dispatchers.default) {
val networksStatuses = if (isNotificationsEnabled) {
multiNetworkStatusSupplier.invoke(MultiNetworkStatusProducer.Params(userWalletId)).first()
withTimeoutOrNull(
FETCH_TIMEOUT_SECONDS.seconds,
{ multiNetworkStatusSupplier.invoke(MultiNetworkStatusProducer.Params(userWalletId)).first() },
) ?: emptySet()
} else {
emptySet()
}
@ -61,4 +66,8 @@ class UserTokensResponseAddressesEnricher @Inject constructor(
response.copy(tokens = enrichedTokens, notifyStatus = isNotificationsEnabled)
}
}
companion object {
private const val FETCH_TIMEOUT_SECONDS = 3
}
}