Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AND-9376 Onboarding: the add cards button is not pressed when backups are completed #3951

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -102,7 +99,6 @@ private class ScanWalletProcessor(
private val derivationsFinder: DerivationsFinder?,
) : ProductCommandProcessor<ScanResponse> {

var primaryCard: PrimaryCard? = null
override fun proceed(
card: CardDTO,
session: CardSession,
Expand Down Expand Up @@ -191,33 +187,42 @@ private class ScanWalletProcessor(
callback: (result: CompletionResult<ScanResponse>) -> 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()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

если взять просто воллет 1 состоянии скипнутого бэкапа, то он тут пройдет в этой таске, а не должен если в приложении нет активной активации

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,
)
}
}
}

private fun deriveKeysIfNeeded(
card: CardDTO,
session: CardSession,
primaryCard: PrimaryCard?,
callback: (result: CompletionResult<ScanResponse>) -> Unit,
) {
val productType = getWalletProductType(card)
Expand Down
1 change: 1 addition & 0 deletions features/wallet-settings/impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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())
}
}
}
Loading