Updated on 2026-08-14
This commit is contained in:
parent
b8b6166a5a
commit
070cc7f250
13 changed files with 46 additions and 13 deletions
|
|
@ -26,4 +26,10 @@ internal sealed class WalletAlertState {
|
|||
override val confirmButtonText: TextReference = resourceReference(id = R.string.common_delete)
|
||||
override val isWarningConfirmButton: Boolean = true
|
||||
}
|
||||
|
||||
object WrongCardIsScanned : WalletAlertState() {
|
||||
override val title: TextReference = resourceReference(R.string.common_warning)
|
||||
override val message: TextReference = resourceReference(R.string.error_wrong_wallet_tapped)
|
||||
override val onConfirmClick: (() -> Unit)? = null
|
||||
}
|
||||
}
|
||||
|
|
@ -71,6 +71,7 @@ import com.tangem.operations.derivation.ExtendedPublicKeysMap
|
|||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import com.tangem.utils.coroutines.JobHolder
|
||||
import com.tangem.utils.coroutines.saveIn
|
||||
import com.tangem.utils.extensions.DELAY_SDK_DIALOG_CLOSE
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.delay
|
||||
|
|
@ -410,12 +411,20 @@ internal class WalletViewModel @Inject constructor(
|
|||
|
||||
viewModelScope.launch(dispatchers.io) {
|
||||
scanCardProcessor.scan()
|
||||
.doOnSuccess {
|
||||
.doOnSuccess { scanResponse ->
|
||||
// If card's public key is null then user wallet will be null
|
||||
val unlockedWallet = UserWalletBuilder(scanResponse = it).build()
|
||||
val scannedWallet = UserWalletBuilder(scanResponse = scanResponse).build()
|
||||
|
||||
if (lockedWallet.walletId == unlockedWallet?.walletId) {
|
||||
saveWalletUseCase(userWallet = unlockedWallet, canOverride = true)
|
||||
if (lockedWallet.walletId == scannedWallet?.walletId) {
|
||||
saveWalletUseCase(userWallet = scannedWallet, canOverride = true)
|
||||
} else {
|
||||
delay(timeMillis = DELAY_SDK_DIALOG_CLOSE)
|
||||
|
||||
uiState = stateFactory.getStateAndTriggerEvent(
|
||||
state = uiState,
|
||||
event = WalletEvent.ShowAlert(state = WalletAlertState.WrongCardIsScanned),
|
||||
setUiState = { uiState = it },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue