Updated on 2026-08-14
This commit is contained in:
parent
fef2ab1274
commit
d5cd5f1951
10 changed files with 33 additions and 20 deletions
|
|
@ -13,6 +13,7 @@ import com.tangem.core.ui.extensions.combinedReference
|
|||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.domain.balancehiding.GetBalanceHidingSettingsUseCase
|
||||
import com.tangem.domain.models.StatusSource
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.currency.CryptoCurrencyStatus
|
||||
import com.tangem.domain.models.currency.yieldSupplyNotAllAmountSupplied
|
||||
|
|
@ -35,6 +36,8 @@ import com.tangem.features.yield.supply.impl.main.model.transformers.YieldSupply
|
|||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import com.tangem.utils.coroutines.DelayedWork
|
||||
import com.tangem.utils.transformer.update
|
||||
import com.tangem.utils.coroutines.JobHolder
|
||||
import com.tangem.utils.coroutines.saveIn
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.*
|
||||
|
|
@ -84,6 +87,7 @@ internal class YieldSupplyModel @Inject constructor(
|
|||
field = MutableStateFlow(false)
|
||||
|
||||
private var lastYieldSupplyStatus: YieldSupplyStatus? = null
|
||||
private val fetchCurrencyJobHolder = JobHolder()
|
||||
|
||||
init {
|
||||
checkIfYieldSupplyIsAvailable()
|
||||
|
|
@ -183,6 +187,19 @@ internal class YieldSupplyModel @Inject constructor(
|
|||
val yieldSupplyStatus = cryptoCurrencyStatus.value.yieldSupplyStatus
|
||||
val tokenProtocolStatus = yieldSupplyRepository.getTokenProtocolStatus(cryptoCurrency)
|
||||
val isActive = yieldSupplyStatus?.isActive == true
|
||||
val isCryptoCurrencyStatusFromCache = cryptoCurrencyStatus.value.sources.networkSource != StatusSource.ACTUAL
|
||||
val processing = uiState.value is YieldSupplyUM.Processing
|
||||
Timber.d(
|
||||
"currentUiState ${uiState.value.javaClass} \n" +
|
||||
"yieldSupplyStatus $yieldSupplyStatus" +
|
||||
"tokenProtocolStatus $tokenProtocolStatus " +
|
||||
"isActive $isActive " +
|
||||
"processing $processing " +
|
||||
"isCryptoCurrencyStatusFromCache $isCryptoCurrencyStatusFromCache",
|
||||
)
|
||||
if (isCryptoCurrencyStatusFromCache && processing) {
|
||||
return
|
||||
}
|
||||
|
||||
when {
|
||||
!isActive && tokenProtocolStatus == YieldSupplyEnterStatus.Enter -> {
|
||||
|
|
@ -215,8 +232,10 @@ internal class YieldSupplyModel @Inject constructor(
|
|||
userWalletId = userWallet.walletId,
|
||||
network = cryptoCurrency.network,
|
||||
),
|
||||
)
|
||||
}
|
||||
).onLeft {
|
||||
fetchCurrencyWithDelay()
|
||||
}
|
||||
}.saveIn(fetchCurrencyJobHolder)
|
||||
}
|
||||
|
||||
private fun loadActiveState(cryptoCurrencyStatus: CryptoCurrencyStatus, yieldSupplyStatus: YieldSupplyStatus) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ internal class YieldSupplyTokenStatusSuccessTransformer(
|
|||
if (!tokenStatus.isActive) return YieldSupplyUM.Unavailable
|
||||
|
||||
return YieldSupplyUM.Available(
|
||||
title = resourceReference(R.string.yield_module_token_details_earn_notification_title),
|
||||
title = resourceReference(
|
||||
R.string.yield_module_token_details_earn_notification_earning_on_your_balance_title,
|
||||
),
|
||||
onClick = onStartEarningClick,
|
||||
apy = tokenStatus.apy.toString(),
|
||||
apyText = combinedReference(
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ internal fun YieldSupplyBlockContent(yieldSupplyUM: YieldSupplyUM, modifier: Mod
|
|||
private fun SupplyAvailable(supplyUM: YieldSupplyUM.Available, modifier: Modifier = Modifier) {
|
||||
SupplyInfo(
|
||||
title = resourceReference(R.string.yield_module_token_details_earn_notification_earning_on_your_balance_title),
|
||||
subtitle = supplyUM.title,
|
||||
subtitle = resourceReference(R.string.yield_module_token_details_earn_notification_description),
|
||||
rewardsApy = supplyUM.apyText,
|
||||
iconTint = TangemTheme.colors.icon.accent,
|
||||
modifier = modifier,
|
||||
|
|
@ -292,12 +292,12 @@ private fun SupplyInfo(
|
|||
if (rewardsApy != null) {
|
||||
Text(
|
||||
text = StringsSigns.DOT,
|
||||
style = TangemTheme.typography.subtitle1,
|
||||
style = TangemTheme.typography.subtitle2,
|
||||
color = TangemTheme.colors.text.tertiary,
|
||||
)
|
||||
Text(
|
||||
text = rewardsApy.resolveReference(),
|
||||
style = TangemTheme.typography.subtitle1,
|
||||
style = TangemTheme.typography.subtitle2,
|
||||
maxLines = 1,
|
||||
color = TangemTheme.colors.text.accent,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue