Updated on 2026-08-14
This commit is contained in:
parent
26ca147cf1
commit
26bffcb155
3 changed files with 25 additions and 31 deletions
|
|
@ -6,7 +6,7 @@ import com.tangem.domain.common.extensions.successOr
|
|||
import com.tangem.tap.features.onboarding.products.wallet.saltPay.SaltPayActivationManager
|
||||
import com.tangem.tap.features.onboarding.products.wallet.saltPay.message.SaltPayActivationError
|
||||
import com.tangem.tap.features.onboarding.products.wallet.saltPay.redux.SaltPayActivationStep
|
||||
import com.tangem.tap.features.onboarding.products.wallet.saltPay.redux.updateActivationStatus
|
||||
import com.tangem.tap.features.onboarding.products.wallet.saltPay.redux.update
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
|
|
@ -19,8 +19,8 @@ class OnboardingSaltPayHelper {
|
|||
manager: SaltPayActivationManager,
|
||||
): Result<Boolean> {
|
||||
return try {
|
||||
val status = manager.updateActivationStatus(null).successOr { return it }
|
||||
val isRegistrationCase = status.step != SaltPayActivationStep.Finished
|
||||
val updatedStep = manager.update(null, null).successOr { return it }
|
||||
val isRegistrationCase = updatedStep != SaltPayActivationStep.Finished
|
||||
val isBackupCase = scanResponse.card.backupStatus?.isActive == false
|
||||
Result.Success(isRegistrationCase || isBackupCase)
|
||||
} catch (ex: Exception) {
|
||||
|
|
@ -30,12 +30,12 @@ class OnboardingSaltPayHelper {
|
|||
}
|
||||
}
|
||||
|
||||
suspend fun testProceedToOnboarding(
|
||||
fun testProceedToOnboarding(
|
||||
scanResponse: ScanResponse,
|
||||
manager: SaltPayActivationManager,
|
||||
): Result<Boolean> = Result.Success(true)
|
||||
|
||||
suspend fun testProceedToMainScreen(
|
||||
fun testProceedToMainScreen(
|
||||
scanResponse: ScanResponse,
|
||||
manager: SaltPayActivationManager,
|
||||
): Result<Boolean> = Result.Success(false)
|
||||
|
|
|
|||
|
|
@ -67,13 +67,13 @@ private fun handleOnboardingSaltPayAction(anyAction: Action, appState: () -> App
|
|||
|
||||
val state = getState()
|
||||
scope.launch {
|
||||
val updateResult = state.saltPayManager.updateActivationStatus(state.amountToClaim).successOr {
|
||||
val updateStep = state.saltPayManager.update(state.step, state.amountToClaim).successOr {
|
||||
onException(it.error)
|
||||
return@launch
|
||||
}
|
||||
|
||||
handleInProgress = false
|
||||
dispatchOnMain(OnboardingSaltPayAction.SetStep(updateResult.step))
|
||||
dispatchOnMain(OnboardingSaltPayAction.SetStep(updateStep))
|
||||
}
|
||||
}
|
||||
is OnboardingSaltPayAction.RegisterCard -> {
|
||||
|
|
@ -246,40 +246,34 @@ fun handleAnalytics(analyticsHandler: GlobalAnalyticsEventHandler, step: SaltPay
|
|||
}
|
||||
}
|
||||
|
||||
data class UpdateResult(
|
||||
val step: SaltPayActivationStep = SaltPayActivationStep.None,
|
||||
val amountToClaim: Amount? = null,
|
||||
)
|
||||
|
||||
suspend fun SaltPayActivationManager.updateActivationStatus(amountToClaim: Amount?): Result<UpdateResult> {
|
||||
suspend fun SaltPayActivationManager.update(
|
||||
currentStep: SaltPayActivationStep?,
|
||||
currentAmountToClaim: Amount?,
|
||||
): Result<SaltPayActivationStep> {
|
||||
Timber.d("updateSaltPayStatus")
|
||||
var updateResult = UpdateResult()
|
||||
|
||||
val saltPayStep = checkRegistration(this).successOr {
|
||||
val step = checkRegistration(this).successOr {
|
||||
return Result.Failure(it.error)
|
||||
}
|
||||
|
||||
checkGasIfNeeded(this, saltPayStep).successOr {
|
||||
checkGasIfNeeded(this, step).successOr {
|
||||
return Result.Failure(it.error)
|
||||
}
|
||||
|
||||
val fetchedAmountToClaim = getAmountToClaimIfNeeded(this, amountToClaim)
|
||||
updateResult = when {
|
||||
// if fetchedAmountToClaim = null -> then it already claimed
|
||||
saltPayStep == SaltPayActivationStep.Claim && fetchedAmountToClaim == null -> {
|
||||
updateResult.copy(
|
||||
step = SaltPayActivationStep.Finished,
|
||||
amountToClaim = fetchedAmountToClaim,
|
||||
)
|
||||
val amountToClaim = getAmountToClaimIfNeeded(this, currentAmountToClaim)
|
||||
|
||||
val processedStep = when {
|
||||
step == SaltPayActivationStep.Claim && amountToClaim == null -> {
|
||||
SaltPayActivationStep.Finished
|
||||
}
|
||||
else -> updateResult.copy(
|
||||
step = saltPayStep,
|
||||
amountToClaim = fetchedAmountToClaim,
|
||||
)
|
||||
step == SaltPayActivationStep.KycReject && currentStep == SaltPayActivationStep.KycReject -> {
|
||||
SaltPayActivationStep.KycStart
|
||||
}
|
||||
else -> step
|
||||
}
|
||||
|
||||
Timber.d("updateSaltPayStatus: success: %s", updateResult)
|
||||
return Result.Success(updateResult)
|
||||
Timber.d("update: success: %s", processedStep)
|
||||
return Result.Success(processedStep)
|
||||
}
|
||||
|
||||
private suspend fun getAmountToClaimIfNeeded(
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ internal class OnboardingSaltPayView(
|
|||
btnOpenSupportChat.hide()
|
||||
btnKycAction.text = getString(R.string.onboarding_button_kyc_start)
|
||||
btnKycAction.setOnClickListener {
|
||||
store.dispatch(OnboardingSaltPayAction.SetStep(SaltPayActivationStep.KycStart))
|
||||
store.dispatch(OnboardingSaltPayAction.Update)
|
||||
}
|
||||
progressButton = SaltPayProgressButton(root)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue