Updated on 2026-08-14
This commit is contained in:
parent
898edd2b16
commit
5516e706aa
10 changed files with 45 additions and 21 deletions
|
|
@ -60,6 +60,7 @@ sealed class BackupAction : Action {
|
|||
data object ErrorInBackupCard : BackupAction()
|
||||
data object StartAddingPrimaryCard : BackupAction()
|
||||
data object ScanPrimaryCard : BackupAction()
|
||||
data class SetHasRing(val hasRing: Boolean) : BackupAction()
|
||||
|
||||
/**
|
||||
* Check for unfinished backup of standard Wallets
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import com.tangem.domain.common.extensions.withIOContext
|
|||
import com.tangem.domain.common.extensions.withMainContext
|
||||
import com.tangem.domain.common.util.cardTypesResolver
|
||||
import com.tangem.domain.models.scan.CardDTO
|
||||
import com.tangem.domain.models.scan.CardDTO.Companion.RING_BATCH_IDS
|
||||
import com.tangem.domain.models.scan.CardDTO.Companion.RING_BATCH_PREFIX
|
||||
import com.tangem.domain.models.scan.ScanResponse
|
||||
import com.tangem.domain.wallets.builder.UserWalletBuilder
|
||||
import com.tangem.domain.wallets.models.Artwork
|
||||
|
|
@ -200,6 +202,13 @@ private fun handleWalletAction(action: Action) {
|
|||
private fun handleFinishOnboardind(scanResponse: ScanResponse) {
|
||||
val backupState = store.state.onboardingWalletState.backupState
|
||||
val updatedScanResponse = updateScanResponseAfterBackup(scanResponse, backupState)
|
||||
|
||||
if (backupState.hasRing) {
|
||||
scope.launch {
|
||||
store.inject(DaggerGraphState::walletsRepository).setHasWalletsWithRing()
|
||||
}
|
||||
}
|
||||
|
||||
OnboardingHelper.trySaveWalletAndNavigateToWalletScreen(
|
||||
scanResponse = updatedScanResponse,
|
||||
accessCode = backupState.accessCode,
|
||||
|
|
@ -496,11 +505,11 @@ private fun handleBackupAction(appState: () -> AppState?, action: BackupAction)
|
|||
}
|
||||
}
|
||||
is BackupAction.WritePrimaryCard -> {
|
||||
val iconScanRes = if (scanResponse?.cardTypesResolver?.isRing() == true) {
|
||||
R.drawable.img_hand_scan_ring
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val isRing = scanResponse?.cardTypesResolver?.isRing() == true
|
||||
val iconScanRes = if (isRing) R.drawable.img_hand_scan_ring else null
|
||||
|
||||
store.dispatchOnMain(BackupAction.SetHasRing(hasRing = isRing))
|
||||
|
||||
backupService.proceedBackup(iconScanRes = iconScanRes) { result ->
|
||||
when (result) {
|
||||
is CompletionResult.Success -> {
|
||||
|
|
@ -513,11 +522,11 @@ private fun handleBackupAction(appState: () -> AppState?, action: BackupAction)
|
|||
is BackupAction.WriteBackupCard -> {
|
||||
val cardIndex = if (action.cardNumber > 0) action.cardNumber - 1 else action.cardNumber
|
||||
val backupCard = backupState.backupCards.getOrNull(cardIndex)
|
||||
val iconScanRes = if (backupCard?.batchId?.startsWith(CardDTO.RING_BATCH_PREFIX) == true) {
|
||||
R.drawable.img_hand_scan_ring
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val isRing = backupCard.isRing()
|
||||
val iconScanRes = if (isRing) R.drawable.img_hand_scan_ring else null
|
||||
|
||||
store.dispatchOnMain(BackupAction.SetHasRing(hasRing = isRing))
|
||||
|
||||
backupService.proceedBackup(iconScanRes = iconScanRes) { result ->
|
||||
when (result) {
|
||||
is CompletionResult.Success -> {
|
||||
|
|
@ -636,6 +645,10 @@ private fun handleBackupAction(appState: () -> AppState?, action: BackupAction)
|
|||
}
|
||||
}
|
||||
|
||||
private fun Card?.isRing(): Boolean {
|
||||
return this?.let { RING_BATCH_IDS.contains(batchId) || batchId.startsWith(RING_BATCH_PREFIX) } ?: false
|
||||
}
|
||||
|
||||
fun updateArtworks(addedBackupCardsCount: Int, card: Card) {
|
||||
mainScope.launch {
|
||||
withIOContext {
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ private object BackupReducer {
|
|||
is BackupAction.FinishBackup -> state.copy(backupStep = BackupStep.Finished)
|
||||
BackupAction.OnAccessCodeDialogClosed -> state.copy(backupStep = BackupStep.AddBackupCards)
|
||||
BackupAction.DiscardBackup -> BackupState()
|
||||
is BackupAction.SetHasRing -> state.copy(hasRing = action.hasRing)
|
||||
else -> state
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ data class BackupState(
|
|||
val isInterruptedBackup: Boolean = false,
|
||||
val showBtnLoading: Boolean = false,
|
||||
val hasBackupError: Boolean = false,
|
||||
val hasRing: Boolean = false,
|
||||
)
|
||||
|
||||
enum class AccessCodeError {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue