diff --git a/app/src/main/java/com/tangem/tap/domain/tasks/product/ScanProductTask.kt b/app/src/main/java/com/tangem/tap/domain/tasks/product/ScanProductTask.kt index 64b248771e..b906a37868 100644 --- a/app/src/main/java/com/tangem/tap/domain/tasks/product/ScanProductTask.kt +++ b/app/src/main/java/com/tangem/tap/domain/tasks/product/ScanProductTask.kt @@ -33,12 +33,9 @@ import com.tangem.operations.backup.StartPrimaryCardLinkingTask import com.tangem.operations.derivation.DeriveMultipleWalletPublicKeysTask import com.tangem.operations.files.ReadFilesTask import com.tangem.operations.issuerAndUserData.ReadIssuerDataCommand -import com.tangem.tap.common.extensions.inject import com.tangem.tap.domain.TapSdkError import com.tangem.tap.mainScope -import com.tangem.tap.proxy.redux.DaggerGraphState import com.tangem.tap.scope -import com.tangem.tap.store import kotlinx.coroutines.launch import kotlin.collections.set @@ -102,7 +99,6 @@ private class ScanWalletProcessor( private val derivationsFinder: DerivationsFinder?, ) : ProductCommandProcessor { - var primaryCard: PrimaryCard? = null override fun proceed( card: CardDTO, session: CardSession, @@ -191,26 +187,34 @@ private class ScanWalletProcessor( callback: (result: CompletionResult) -> Unit, ) { mainScope.launch { - val activationInProgress = store.inject(DaggerGraphState::cardRepository) - .isActivationInProgress(card.cardId) - - @Suppress("ComplexCondition") - if (card.backupStatus == CardDTO.BackupStatus.NoBackup && card.wallets.isNotEmpty() && - activationInProgress - ) { + if (card.backupStatus == CardDTO.BackupStatus.NoBackup && card.wallets.isNotEmpty()) { StartPrimaryCardLinkingTask().run(session) { linkingResult -> when (linkingResult) { is CompletionResult.Success -> { - primaryCard = linkingResult.data - deriveKeysIfNeeded(card, session, callback) + deriveKeysIfNeeded( + card = card, + session = session, + primaryCard = linkingResult.data, + callback = callback, + ) } is CompletionResult.Failure -> { - deriveKeysIfNeeded(card, session, callback) + deriveKeysIfNeeded( + card = card, + session = session, + primaryCard = null, + callback = callback, + ) } } } } else { - deriveKeysIfNeeded(card, session, callback) + deriveKeysIfNeeded( + card = card, + session = session, + primaryCard = null, + callback = callback, + ) } } } @@ -218,6 +222,7 @@ private class ScanWalletProcessor( private fun deriveKeysIfNeeded( card: CardDTO, session: CardSession, + primaryCard: PrimaryCard?, callback: (result: CompletionResult) -> Unit, ) { val productType = getWalletProductType(card) diff --git a/features/wallet-settings/impl/build.gradle.kts b/features/wallet-settings/impl/build.gradle.kts index cdd56e2fe8..e16d70c0f7 100644 --- a/features/wallet-settings/impl/build.gradle.kts +++ b/features/wallet-settings/impl/build.gradle.kts @@ -16,6 +16,7 @@ dependencies { /* Project - API */ implementation(projects.features.walletSettings.api) implementation(projects.features.manageTokens.api) + implementation(projects.features.onboardingV2.api) /* Project - Core */ implementation(projects.core.decompose) diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt index e9bb1a9f44..f60726cae9 100644 --- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt +++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt @@ -33,6 +33,7 @@ import com.tangem.feature.walletsettings.entity.WalletSettingsItemUM import com.tangem.feature.walletsettings.entity.WalletSettingsUM import com.tangem.feature.walletsettings.impl.R import com.tangem.feature.walletsettings.utils.ItemsBuilder +import com.tangem.features.onboarding.v2.OnboardingV2FeatureToggles import com.tangem.utils.coroutines.CoroutineDispatcherProvider import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.persistentListOf @@ -55,6 +56,7 @@ internal class WalletSettingsModel @Inject constructor( private val analyticsContextProxy: AnalyticsContextProxy, private val reduxStateHolder: ReduxStateHolder, private val getShouldSaveUserWalletsSyncUseCase: ShouldSaveUserWalletsSyncUseCase, + private val onboardingV2FeatureToggles: OnboardingV2FeatureToggles, ) : Model() { val params: WalletSettingsComponent.Params = paramsContainer.require() @@ -149,15 +151,25 @@ internal class WalletSettingsModel @Inject constructor( private fun onLinkMoreCardsClick(scanResponse: ScanResponse) { analyticsEventHandler.send(Settings.ButtonCreateBackup) - analyticsContextProxy.addContext(scanResponse) + if (onboardingV2FeatureToggles.isOnboardingV2Enabled) { + router.push( + AppRoute.Onboarding( + scanResponse = scanResponse, + startFromBackup = true, + mode = AppRoute.Onboarding.Mode.AddBackup, + ), + ) + } else { + analyticsContextProxy.addContext(scanResponse) - reduxStateHolder.dispatch( - LegacyAction.StartOnboardingProcess( - scanResponse = scanResponse, - canSkipBackup = false, - ), - ) + reduxStateHolder.dispatch( + LegacyAction.StartOnboardingProcess( + scanResponse = scanResponse, + canSkipBackup = false, + ), + ) - router.push(AppRoute.OnboardingWallet()) + router.push(AppRoute.OnboardingWallet()) + } } }