Updated on 2026-08-14
This commit is contained in:
parent
841423843a
commit
20c985d859
3 changed files with 23 additions and 16 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.tap.features.details.redux
|
||||
|
||||
import com.tangem.blockchain.common.Wallet
|
||||
import com.tangem.common.card.Card
|
||||
import com.tangem.operations.pins.CheckUserCodesResponse
|
||||
import com.tangem.tap.common.redux.NotificationAction
|
||||
import com.tangem.tap.common.redux.global.FiatCurrencyName
|
||||
|
|
@ -50,7 +51,7 @@ sealed class DetailsAction : Action {
|
|||
}
|
||||
|
||||
sealed class ManageSecurity : DetailsAction() {
|
||||
data class CheckCurrentSecurityOption(val cardId: String?) : ManageSecurity()
|
||||
data class CheckCurrentSecurityOption(val card: Card) : ManageSecurity()
|
||||
data class SetCurrentOption(val userCodes: CheckUserCodesResponse) : ManageSecurity()
|
||||
object OpenSecurity : ManageSecurity()
|
||||
data class SelectOption(val option: SecurityOption) : ManageSecurity()
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package com.tangem.tap.features.details.redux
|
||||
|
||||
import com.tangem.common.CompletionResult
|
||||
import com.tangem.common.card.FirmwareVersion
|
||||
import com.tangem.common.core.TangemSdkError
|
||||
import com.tangem.common.services.Result
|
||||
import com.tangem.operations.pins.CheckUserCodesResponse
|
||||
import com.tangem.tap.common.analytics.FirebaseAnalyticsHandler
|
||||
import com.tangem.tap.common.extensions.dispatchNotification
|
||||
import com.tangem.tap.common.extensions.dispatchOnMain
|
||||
|
|
@ -141,16 +143,22 @@ class DetailsMiddleware {
|
|||
fun handle(action: DetailsAction.ManageSecurity) {
|
||||
when (action) {
|
||||
is DetailsAction.ManageSecurity.CheckCurrentSecurityOption -> {
|
||||
scope.launch {
|
||||
when (val response = tangemSdkManager.checkUserCodes(action.cardId)) {
|
||||
is CompletionResult.Success -> {
|
||||
store.dispatchOnMain(
|
||||
DetailsAction.ManageSecurity.SetCurrentOption(response.data)
|
||||
)
|
||||
store.dispatchOnMain(DetailsAction.ManageSecurity.OpenSecurity)
|
||||
}
|
||||
is CompletionResult.Failure -> {
|
||||
|
||||
if (action.card.firmwareVersion >= FirmwareVersion.IsAccessCodeStatusAvailable) {
|
||||
// for a card that meets this condition, we can get these statuses from it
|
||||
val simulatedResponse = CheckUserCodesResponse(
|
||||
action.card.isAccessCodeSet, action.card.isPasscodeSet ?: false
|
||||
)
|
||||
store.dispatch(DetailsAction.ManageSecurity.SetCurrentOption(simulatedResponse))
|
||||
store.dispatch(DetailsAction.ManageSecurity.OpenSecurity)
|
||||
} else {
|
||||
scope.launch {
|
||||
when (val response = tangemSdkManager.checkUserCodes(action.card.cardId)) {
|
||||
is CompletionResult.Success -> {
|
||||
store.dispatchOnMain(DetailsAction.ManageSecurity.SetCurrentOption(response.data))
|
||||
store.dispatchOnMain(DetailsAction.ManageSecurity.OpenSecurity)
|
||||
}
|
||||
is CompletionResult.Failure -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -197,7 +205,7 @@ class DetailsMiddleware {
|
|||
actionToLog = FirebaseAnalyticsHandler.ActionToLog.ChangeSecOptions,
|
||||
parameters = mapOf(
|
||||
FirebaseAnalyticsHandler.AnalyticsParam.NEW_SECURITY_OPTION to
|
||||
(selectedOption?.name ?: "")
|
||||
(selectedOption?.name ?: "")
|
||||
),
|
||||
card = store.state.detailsState.scanResponse?.card
|
||||
)
|
||||
|
|
|
|||
|
|
@ -119,9 +119,7 @@ class DetailsFragment : Fragment(R.layout.fragment_details), StoreSubscriber<Det
|
|||
}
|
||||
|
||||
tv_security_title.setOnClickListener {
|
||||
store.dispatch(DetailsAction.ManageSecurity.CheckCurrentSecurityOption(
|
||||
state.scanResponse?.card?.cardId
|
||||
))
|
||||
store.dispatch(DetailsAction.ManageSecurity.CheckCurrentSecurityOption(state.scanResponse!!.card))
|
||||
}
|
||||
|
||||
val currentSecurity = when (state.securityScreenState?.currentOption) {
|
||||
|
|
@ -133,7 +131,7 @@ class DetailsFragment : Fragment(R.layout.fragment_details), StoreSubscriber<Det
|
|||
currentSecurity?.let { tv_security.text = getString(it) }
|
||||
|
||||
if (state.appCurrencyState.showAppCurrencyDialog &&
|
||||
!state.appCurrencyState.fiatCurrencies.isNullOrEmpty()) {
|
||||
!state.appCurrencyState.fiatCurrencies.isNullOrEmpty()) {
|
||||
currencySelectionDialog.show(
|
||||
state.appCurrencyState.fiatCurrencies,
|
||||
state.appCurrencyState.fiatCurrencyName,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue