From 7da0c4651c0253c8589a531858b00bdd6cd5e53d Mon Sep 17 00:00:00 2001 From: Vlad Kozarez Date: Thu, 12 Dec 2024 14:00:35 +0300 Subject: [PATCH] AND-9446 reload quotes on crash delay --- .../tokens/operations/CurrenciesStatusesLceOperations.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrenciesStatusesLceOperations.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrenciesStatusesLceOperations.kt index 96f106e244..4e44106c54 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrenciesStatusesLceOperations.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrenciesStatusesLceOperations.kt @@ -18,6 +18,7 @@ import com.tangem.domain.tokens.repository.NetworksRepository import com.tangem.domain.tokens.repository.QuotesRepository import com.tangem.domain.wallets.models.UserWalletId import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.delay import kotlinx.coroutines.flow.* internal class CurrenciesStatusesLceOperations( @@ -169,6 +170,8 @@ internal class CurrenciesStatusesLceOperations( .map, Either>> { it.right() } .retryWhen { cause, _ -> emit(TokenListError.DataError(cause).left()) + // adding delay before retry to avoid spam when flow restarted + delay(RETRY_QUOTES_DELAY) true } .distinctUntilChanged() @@ -215,4 +218,8 @@ internal class CurrenciesStatusesLceOperations( else -> null } } + + companion object { + private const val RETRY_QUOTES_DELAY = 2000L + } }