From 22cbfe33ed1e0821224a6889bb29a3fab950894a Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 1 Dec 2025 18:30:35 +0400 Subject: [PATCH] Updated on 2026-08-14 --- .../wallet/model/intents/WalletClickIntents.kt | 3 +++ .../supply/impl/main/model/YieldSupplyModel.kt | 16 +++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletClickIntents.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletClickIntents.kt index 2bc5de2881..da14212983 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletClickIntents.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletClickIntents.kt @@ -7,6 +7,7 @@ import com.tangem.domain.onramp.FetchHotCryptoUseCase import com.tangem.domain.settings.NeverToShowWalletsScrollPreview import com.tangem.domain.wallets.usecase.GetSelectedWalletSyncUseCase import com.tangem.domain.wallets.usecase.SelectWalletUseCase +import com.tangem.domain.yield.supply.usecase.YieldSupplyApyUpdateUseCase import com.tangem.feature.wallet.presentation.router.InnerWalletRouter import com.tangem.feature.wallet.presentation.wallet.domain.OnrampStatusFactory import com.tangem.feature.wallet.presentation.wallet.domain.WalletContentFetcher @@ -40,6 +41,7 @@ internal class WalletClickIntents @Inject constructor( private val fetchHotCryptoUseCase: FetchHotCryptoUseCase, private val onrampStatusFactory: OnrampStatusFactory, private val tangemPayIntents: TangemPayClickIntentsImplementor, + private val yieldSupplyApyUpdateUseCase: YieldSupplyApyUpdateUseCase, ) : BaseWalletClickIntents(), WalletCardClickIntents by walletCardClickIntentsImplementor, WalletWarningsClickIntents by warningsClickIntentsImplementer, @@ -126,6 +128,7 @@ internal class WalletClickIntents @Inject constructor( async { rampStateManager.fetchSellServiceData() }.let(::add) async { fetchHotCryptoUseCase() }.let(::add) async { tangemPayIntents.onPullToRefresh() }.let(::add) + async { yieldSupplyApyUpdateUseCase() }.let(::add) } .awaitAll() diff --git a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/main/model/YieldSupplyModel.kt b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/main/model/YieldSupplyModel.kt index 650ba7d090..95f483022e 100644 --- a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/main/model/YieldSupplyModel.kt +++ b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/main/model/YieldSupplyModel.kt @@ -46,6 +46,7 @@ import kotlinx.coroutines.launch import timber.log.Timber import javax.inject.Inject import kotlin.properties.Delegates +import java.util.concurrent.atomic.AtomicBoolean @Suppress("LongParameterList", "LargeClass") @ModelScoped @@ -74,10 +75,10 @@ internal class YieldSupplyModel @Inject constructor( private val cryptoCurrency = params.cryptoCurrency var userWallet: UserWallet by Delegates.notNull() - private var lastYieldSupplyStatus: YieldSupplyStatus? = null private val fetchCurrencyJobHolder = JobHolder() private var lastStatusCheckTimestamp = 0L + private val isFirstCryptoCurrencyStatusEmission = AtomicBoolean(true) init { checkIfYieldSupplyIsAvailable() @@ -105,6 +106,9 @@ internal class YieldSupplyModel @Inject constructor( ).onEach { maybeCryptoCurrency -> maybeCryptoCurrency.fold( ifRight = { cryptoCurrencyStatus -> + if (isFirstCryptoCurrencyStatusEmission.compareAndSet(true, false)) { + sendInfoAboutProtocolStatus(cryptoCurrencyStatus) + } onCryptoCurrencyStatusUpdated(cryptoCurrencyStatus) }, ifLeft = { @@ -242,7 +246,6 @@ internal class YieldSupplyModel @Inject constructor( cryptoCurrency = cryptoCurrency, yieldSupplyEnterStatus = null, ) - sendInfoAboutProtocolStatus(cryptoCurrencyStatus) if (yieldSupplyStatus?.isActive == true) { loadActiveState( cryptoCurrencyStatus = cryptoCurrencyStatus, @@ -353,7 +356,6 @@ internal class YieldSupplyModel @Inject constructor( } private fun sendInfoAboutProtocolStatus(cryptoCurrencyStatus: CryptoCurrencyStatus) { - if (lastYieldSupplyStatus == cryptoCurrencyStatus.value.yieldSupplyStatus) return val token = cryptoCurrency as? CryptoCurrency.Token ?: return val address = cryptoCurrencyStatus.value.networkAddress?.defaultAddress?.value ?: return modelScope.launch(dispatchers.default) { @@ -362,13 +364,9 @@ internal class YieldSupplyModel @Inject constructor( userWalletId = userWallet.walletId, cryptoCurrency = token, address = address, - ).onRight { - lastYieldSupplyStatus = cryptoCurrencyStatus.value.yieldSupplyStatus - } + ) } else { - yieldSupplyDeactivateUseCase(token, address).onRight { - lastYieldSupplyStatus = cryptoCurrencyStatus.value.yieldSupplyStatus - } + yieldSupplyDeactivateUseCase(token, address) } } }