Updated on 2026-08-14
This commit is contained in:
parent
ffaffe1274
commit
22cbfe33ed
2 changed files with 10 additions and 9 deletions
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue