Updated on 2026-08-14
This commit is contained in:
commit
c28437209d
5 changed files with 29 additions and 13 deletions
|
|
@ -23,5 +23,10 @@ internal fun resolveBoostBlockState(qualificationEndDate: Instant?, now: Instant
|
|||
qualificationEndDate == null -> BoostBlockState.Hidden
|
||||
now >= qualificationEndDate + AWAITING_PAYOUT_WINDOW -> BoostBlockState.Hidden
|
||||
now >= qualificationEndDate -> BoostBlockState.AwaitingPayout
|
||||
else -> BoostBlockState.DaysLeft(days = (qualificationEndDate - now).inWholeDays.toInt())
|
||||
else -> {
|
||||
val remaining = qualificationEndDate - now
|
||||
val fullDays = remaining.inWholeDays
|
||||
val daysLeft = if (remaining > fullDays.days) fullDays + 1 else fullDays
|
||||
BoostBlockState.DaysLeft(days = daysLeft.toInt())
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,6 @@ import com.tangem.core.decompose.di.ModelScoped
|
|||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.core.decompose.model.ParamsContainer
|
||||
import com.tangem.core.navigation.url.UrlOpener
|
||||
import com.tangem.core.ui.DesignFeatureToggles
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.combinedReference
|
||||
import com.tangem.core.ui.extensions.pluralReference
|
||||
|
|
@ -74,7 +73,6 @@ internal class YieldSupplyActiveModel @Inject constructor(
|
|||
private val yieldSupplyGetDustMinAmountUseCase: YieldSupplyGetDustMinAmountUseCase,
|
||||
private val getYieldBoostStatusUseCase: GetYieldBoostStatusUseCase,
|
||||
private val yieldSupplyFeatureToggles: YieldSupplyFeatureToggles,
|
||||
private val designFeatureToggles: DesignFeatureToggles,
|
||||
private val boostStoryPreloader: YieldBoostStoryPreloader,
|
||||
) : Model(), YieldSupplyStopEarningComponent.ModelCallback,
|
||||
YieldSupplyApproveComponent.ModelCallback {
|
||||
|
|
@ -239,7 +237,6 @@ internal class YieldSupplyActiveModel @Inject constructor(
|
|||
|
||||
private fun loadBoostBlock() {
|
||||
if (!yieldSupplyFeatureToggles.isYieldPromoEnabled) return
|
||||
if (designFeatureToggles.isRedesignEnabled) return
|
||||
modelScope.launch(dispatchers.io) {
|
||||
val token = cryptoCurrency as? CryptoCurrency.Token ?: return@launch
|
||||
val cached = getYieldBoostStatusUseCase(userWalletId).getOrNull()
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import com.tangem.core.decompose.di.ModelScoped
|
|||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.core.decompose.model.ParamsContainer
|
||||
import com.tangem.core.decompose.navigation.Router
|
||||
import com.tangem.core.ui.DesignFeatureToggles
|
||||
import com.tangem.domain.account.status.supplier.SingleAccountStatusListSupplier
|
||||
import com.tangem.domain.account.status.utils.CryptoCurrencyStatusOperations.getCryptoCurrencyStatus
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
|
|
@ -33,7 +32,6 @@ internal class YieldSupplyEntryModel @Inject constructor(
|
|||
private val singleAccountStatusListSupplier: SingleAccountStatusListSupplier,
|
||||
private val isYieldBoostPromoEnabledForTokenUseCase: IsYieldBoostPromoEnabledForTokenUseCase,
|
||||
private val yieldSupplyFeatureToggles: YieldSupplyFeatureToggles,
|
||||
private val designFeatureToggles: DesignFeatureToggles,
|
||||
) : Model() {
|
||||
|
||||
private val params = paramsContainer.require<YieldSupplyEntryComponent.Params>()
|
||||
|
|
@ -99,7 +97,6 @@ internal class YieldSupplyEntryModel @Inject constructor(
|
|||
YieldSupplyEntryRoute.Active(cryptoCurrency = token)
|
||||
} else {
|
||||
val isPromoEnabled = yieldSupplyFeatureToggles.isYieldPromoEnabled &&
|
||||
!designFeatureToggles.isRedesignEnabled &&
|
||||
isYieldBoostPromoEnabledForTokenUseCase(userWalletId, token).getOrElse { false }
|
||||
YieldSupplyEntryRoute.Promo(
|
||||
cryptoCurrency = token,
|
||||
|
|
|
|||
|
|
@ -26,13 +26,34 @@ internal class BoostBlockStateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN qualificationEndDate less than a day away WHEN resolve THEN DaysLeft zero`() {
|
||||
fun `GIVEN qualificationEndDate less than a day away WHEN resolve THEN DaysLeft one`() {
|
||||
val result = resolveBoostBlockState(
|
||||
qualificationEndDate = Instant.parse("2026-05-28T18:00:00Z"),
|
||||
now = now,
|
||||
)
|
||||
|
||||
assertThat(result).isEqualTo(BoostBlockState.DaysLeft(days = 0))
|
||||
assertThat(result).isEqualTo(BoostBlockState.DaysLeft(days = 1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN qualificationEndDate just over a day away WHEN resolve THEN DaysLeft rounds up`() {
|
||||
val result = resolveBoostBlockState(
|
||||
// 1d 1h away — rounds up to 2
|
||||
qualificationEndDate = Instant.parse("2026-05-29T01:00:00Z"),
|
||||
now = now,
|
||||
)
|
||||
|
||||
assertThat(result).isEqualTo(BoostBlockState.DaysLeft(days = 2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN qualificationEndDate exactly whole days away WHEN resolve THEN DaysLeft exact`() {
|
||||
val result = resolveBoostBlockState(
|
||||
qualificationEndDate = Instant.parse("2026-05-30T00:00:00Z"),
|
||||
now = now,
|
||||
)
|
||||
|
||||
assertThat(result).isEqualTo(BoostBlockState.DaysLeft(days = 2))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import com.google.common.truth.Truth.assertThat
|
|||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.decompose.model.MutableParamsContainer
|
||||
import com.tangem.core.navigation.url.UrlOpener
|
||||
import com.tangem.core.ui.DesignFeatureToggles
|
||||
import com.tangem.common.routing.AppRouter
|
||||
import com.tangem.domain.account.status.supplier.SingleAccountStatusListSupplier
|
||||
import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
|
||||
|
|
@ -56,7 +55,6 @@ class YieldSupplyActiveModelBoostBlockTest {
|
|||
private val yieldSupplyGetDustMinAmountUseCase: YieldSupplyGetDustMinAmountUseCase = mockk(relaxed = true)
|
||||
private val getYieldBoostStatusUseCase: GetYieldBoostStatusUseCase = mockk(relaxed = true)
|
||||
private val yieldSupplyFeatureToggles: YieldSupplyFeatureToggles = mockk(relaxed = true)
|
||||
private val designFeatureToggles: DesignFeatureToggles = mockk(relaxed = true)
|
||||
private val boostStoryPreloader: YieldBoostStoryPreloader = mockk(relaxed = true)
|
||||
private val analyticsHandler: AnalyticsEventHandler = mockk(relaxed = true)
|
||||
|
||||
|
|
@ -86,7 +84,6 @@ class YieldSupplyActiveModelBoostBlockTest {
|
|||
@BeforeEach
|
||||
fun setUp() {
|
||||
every { yieldSupplyFeatureToggles.isYieldPromoEnabled } returns true
|
||||
every { designFeatureToggles.isRedesignEnabled } returns false
|
||||
every { getUserWalletUseCase.invoke(userWalletId) } returns userWallet.right()
|
||||
every { singleAccountStatusListSupplier.invoke(userWalletId) } returns emptyFlow()
|
||||
coEvery { getSelectedAppCurrencyUseCase.invokeSync() } returns AppCurrency.Default.right()
|
||||
|
|
@ -112,7 +109,6 @@ class YieldSupplyActiveModelBoostBlockTest {
|
|||
yieldSupplyGetDustMinAmountUseCase = yieldSupplyGetDustMinAmountUseCase,
|
||||
getYieldBoostStatusUseCase = getYieldBoostStatusUseCase,
|
||||
yieldSupplyFeatureToggles = yieldSupplyFeatureToggles,
|
||||
designFeatureToggles = designFeatureToggles,
|
||||
boostStoryPreloader = boostStoryPreloader,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue