diff --git a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/transformers/SetConfirmationStateResetAssentTransformer.kt b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/transformers/SetConfirmationStateResetAssentTransformer.kt new file mode 100644 index 0000000000..ee866db72c --- /dev/null +++ b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/transformers/SetConfirmationStateResetAssentTransformer.kt @@ -0,0 +1,23 @@ +package com.tangem.features.staking.impl.presentation.state.transformers + +import com.tangem.features.staking.impl.presentation.state.InnerConfirmationStakingState +import com.tangem.features.staking.impl.presentation.state.StakingStates +import com.tangem.features.staking.impl.presentation.state.StakingUiState +import com.tangem.utils.transformer.Transformer + +internal object SetConfirmationStateResetAssentTransformer : Transformer { + override fun transform(prevState: StakingUiState): StakingUiState { + val confirmationState = prevState.confirmationState + return prevState.copy( + confirmationState = if (confirmationState is StakingStates.ConfirmationState.Data) { + confirmationState.copy( + isPrimaryButtonEnabled = true, + innerState = InnerConfirmationStakingState.ASSENT, + validatorState = confirmationState.validatorState.copySealed(isClickable = true), + ) + } else { + confirmationState + }, + ) + } +} \ No newline at end of file diff --git a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/viewmodel/StakingViewModel.kt b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/viewmodel/StakingViewModel.kt index a79ffd5875..d6869e83d1 100644 --- a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/viewmodel/StakingViewModel.kt +++ b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/viewmodel/StakingViewModel.kt @@ -253,6 +253,7 @@ internal class StakingViewModel @Inject constructor( ).getOrElse { Timber.e(it.toString()) stakingEventFactory.createStakingErrorAlert(it) + stateController.update(SetConfirmationStateResetAssentTransformer) return@launch } @@ -266,6 +267,7 @@ internal class StakingViewModel @Inject constructor( ).getOrElse { Timber.e(it.toString()) stakingEventFactory.createStakingErrorAlert(it) + stateController.update(SetConfirmationStateResetAssentTransformer) return@launch } @@ -469,6 +471,7 @@ internal class StakingViewModel @Inject constructor( ), ) stakingEventFactory.createGenericErrorAlert(error.message ?: error.toString()) + stateController.update(SetConfirmationStateResetAssentTransformer) return@launch }, ifRight = { it }, @@ -489,6 +492,7 @@ internal class StakingViewModel @Inject constructor( ), ) stakingEventFactory.createSendTransactionErrorAlert(error) + stateController.update(SetConfirmationStateResetAssentTransformer) }, ifRight = { stateController.update(SetApprovalInProgressTransformer) @@ -687,6 +691,7 @@ internal class StakingViewModel @Inject constructor( ifLeft = { Timber.e(it.toString()) stakingEventFactory.createGenericErrorAlert(it.toString()) + stateController.update(SetConfirmationStateResetAssentTransformer) }, ) getCryptoCurrencyStatusSyncUseCase(userWalletId, cryptoCurrencyId).fold( @@ -711,6 +716,7 @@ internal class StakingViewModel @Inject constructor( ifLeft = { Timber.e(it.toString()) stakingEventFactory.createGenericErrorAlert(it.toString()) + stateController.update(SetConfirmationStateResetAssentTransformer) }, ) } @@ -759,6 +765,7 @@ internal class StakingViewModel @Inject constructor( ), ) stakingEventFactory.createSendTransactionErrorAlert(error) + stateController.update(SetConfirmationStateResetAssentTransformer) }, ifRight = { transactionHashes -> transactionsInProgress.clear()