Updated on 2026-08-14
This commit is contained in:
commit
fc91ec19b6
9 changed files with 27 additions and 86 deletions
|
|
@ -4,6 +4,7 @@ import com.tangem.datasource.local.card.UsedCardInfo
|
|||
import com.tangem.datasource.local.card.UsedCardsStore
|
||||
import com.tangem.domain.card.repository.CardRepository
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import com.tangem.utils.extensions.addOrReplace
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.channelFlow
|
||||
import kotlinx.coroutines.launch
|
||||
|
|
@ -42,12 +43,7 @@ internal class DefaultCardRepository(
|
|||
}
|
||||
|
||||
private fun List<UsedCardInfo>.updateCard(cardId: String): List<UsedCardInfo> {
|
||||
return map { cardInfo ->
|
||||
if (cardInfo.cardId == cardId) {
|
||||
cardInfo.copy(isScanned = true)
|
||||
} else {
|
||||
cardInfo
|
||||
}
|
||||
}
|
||||
val card = find { it.cardId == cardId } ?: UsedCardInfo(cardId = cardId, isScanned = true)
|
||||
return addOrReplace(item = card.copy(isScanned = true), predicate = { it.cardId == cardId })
|
||||
}
|
||||
}
|
||||
|
|
@ -5,9 +5,6 @@ import com.tangem.core.ui.extensions.TextReference
|
|||
|
||||
@Immutable
|
||||
internal sealed class WalletAlertState {
|
||||
|
||||
data class WalletAlreadySignedHashes(val onUnderstandClick: () -> Unit) : WalletAlertState()
|
||||
|
||||
data class DefaultAlert(
|
||||
val title: TextReference,
|
||||
val message: TextReference,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,5 @@ internal sealed class WalletEvent {
|
|||
|
||||
data class CopyAddress(val address: String) : WalletEvent()
|
||||
|
||||
data class ShowWalletAlreadySignedHashesMessage(val onUnderstandClick: () -> Unit) : WalletEvent()
|
||||
|
||||
data class RateApp(val onDismissClick: () -> Unit) : WalletEvent()
|
||||
}
|
||||
|
|
@ -57,6 +57,7 @@ sealed class WalletNotification(val config: NotificationConfig) {
|
|||
subtitle: TextReference,
|
||||
buttonsState: NotificationConfig.ButtonsState? = null,
|
||||
onClick: (() -> Unit)? = null,
|
||||
onCloseClick: (() -> Unit)? = null,
|
||||
) : WalletNotification(
|
||||
config = NotificationConfig(
|
||||
title = title,
|
||||
|
|
@ -64,6 +65,7 @@ sealed class WalletNotification(val config: NotificationConfig) {
|
|||
iconResId = R.drawable.img_attention_20,
|
||||
buttonsState = buttonsState,
|
||||
onClick = onClick,
|
||||
onCloseClick = onCloseClick,
|
||||
),
|
||||
) {
|
||||
|
||||
|
|
@ -91,15 +93,10 @@ sealed class WalletNotification(val config: NotificationConfig) {
|
|||
subtitle = stringReference(value = errorMessage),
|
||||
)
|
||||
|
||||
object NumberOfSignedHashesIncorrect : Warning(
|
||||
data class NumberOfSignedHashesIncorrect(val onCloseClick: () -> Unit) : Warning(
|
||||
title = resourceReference(id = R.string.common_warning),
|
||||
subtitle = resourceReference(id = R.string.alert_card_signed_transactions),
|
||||
)
|
||||
|
||||
data class MultiWalletSignedHashesIncorrect(val onClick: () -> Unit) : Warning(
|
||||
title = resourceReference(id = R.string.common_warning),
|
||||
subtitle = resourceReference(id = R.string.warning_signed_tx_previously),
|
||||
onClick = onClick,
|
||||
onCloseClick = onCloseClick,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,32 +11,12 @@ import com.tangem.feature.wallet.presentation.wallet.state.WalletAlertState
|
|||
@Composable
|
||||
internal fun WalletAlert(config: WalletAlertState, onDismiss: () -> Unit) {
|
||||
when (config) {
|
||||
is WalletAlertState.WalletAlreadySignedHashes -> {
|
||||
WalletAlreadySignedHashesAlert(config = config, onDismiss = onDismiss)
|
||||
}
|
||||
is WalletAlertState.DefaultAlert -> {
|
||||
DefaultAlert(config = config, onDismiss = onDismiss)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun WalletAlreadySignedHashesAlert(config: WalletAlertState.WalletAlreadySignedHashes, onDismiss: () -> Unit) {
|
||||
BasicDialog(
|
||||
message = stringResource(id = R.string.alert_signed_hashes_message),
|
||||
confirmButton = DialogButton(
|
||||
title = stringResource(id = R.string.common_understand),
|
||||
onClick = {
|
||||
config.onUnderstandClick()
|
||||
onDismiss()
|
||||
},
|
||||
),
|
||||
onDismissDialog = onDismiss,
|
||||
title = stringResource(id = R.string.warning_important_security_info, "\u26A0"),
|
||||
dismissButton = DialogButton(title = stringResource(id = R.string.common_cancel), onClick = onDismiss),
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun DefaultAlert(config: WalletAlertState.DefaultAlert, onDismiss: () -> Unit) {
|
||||
val confirmButton: DialogButton
|
||||
|
|
|
|||
|
|
@ -47,11 +47,6 @@ internal fun WalletEventEffect(
|
|||
is WalletEvent.CopyAddress -> {
|
||||
clipboardManager.setText(AnnotatedString(value.address))
|
||||
}
|
||||
is WalletEvent.ShowWalletAlreadySignedHashesMessage -> {
|
||||
onAlertConfigSet(
|
||||
WalletAlertState.WalletAlreadySignedHashes(onUnderstandClick = value.onUnderstandClick),
|
||||
)
|
||||
}
|
||||
is WalletEvent.ShowAlert -> {
|
||||
onAlertConfigSet(
|
||||
WalletAlertState.DefaultAlert(
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ internal interface WalletClickIntents {
|
|||
|
||||
fun onBackupCardClick()
|
||||
|
||||
fun onMultiWalletSignedHashesNotificationClick()
|
||||
fun onSignedHashesNotificationCloseClick()
|
||||
|
||||
fun onLikeAppClick()
|
||||
|
||||
|
|
|
|||
|
|
@ -137,28 +137,6 @@ internal class WalletNotificationsListFactory(
|
|||
element = WalletNotification.Warning.SomeNetworksUnreachable,
|
||||
condition = cryptoCurrencyList.hasUnreachableNetworks(),
|
||||
)
|
||||
|
||||
if (cardTypesResolver.isBackupForbidden()) {
|
||||
addIf(
|
||||
element = WalletNotification.Warning.NumberOfSignedHashesIncorrect,
|
||||
condition = checkSignedHashes(
|
||||
cardTypesResolver = cardTypesResolver,
|
||||
isDemo = isDemo,
|
||||
wasCardScanned,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
addIf(
|
||||
element = WalletNotification.Warning.MultiWalletSignedHashesIncorrect(
|
||||
onClick = clickIntents::onMultiWalletSignedHashesNotificationClick,
|
||||
),
|
||||
condition = checkSignedHashes(
|
||||
cardTypesResolver = cardTypesResolver,
|
||||
isDemo = isDemo,
|
||||
wasCardScanned,
|
||||
),
|
||||
)
|
||||
}
|
||||
} else {
|
||||
addIf(
|
||||
element = WalletNotification.Warning.NetworksUnreachable,
|
||||
|
|
@ -171,8 +149,14 @@ internal class WalletNotificationsListFactory(
|
|||
}
|
||||
|
||||
addIf(
|
||||
element = WalletNotification.Warning.NumberOfSignedHashesIncorrect,
|
||||
condition = checkSignedHashes(cardTypesResolver, isDemo, wasCardScanned),
|
||||
element = WalletNotification.Warning.NumberOfSignedHashesIncorrect(
|
||||
onCloseClick = clickIntents::onSignedHashesNotificationCloseClick,
|
||||
),
|
||||
condition = checkSignedHashes(
|
||||
cardTypesResolver = cardTypesResolver,
|
||||
isDemo = isDemo,
|
||||
wasCardScanned = wasCardScanned,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -193,13 +177,16 @@ internal class WalletNotificationsListFactory(
|
|||
?.errorMessage
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning is being shown for single wallet cards only
|
||||
*/
|
||||
private fun checkSignedHashes(
|
||||
cardTypesResolver: CardTypesResolver,
|
||||
isDemo: Boolean,
|
||||
wasCardScanned: Boolean,
|
||||
): Boolean {
|
||||
return cardTypesResolver.isReleaseFirmwareType() && cardTypesResolver.hasWalletSignedHashes() && !isDemo &&
|
||||
!wasCardScanned
|
||||
return cardTypesResolver.isReleaseFirmwareType() && !cardTypesResolver.isTangemTwins() &&
|
||||
cardTypesResolver.hasWalletSignedHashes() && !isDemo && !wasCardScanned
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
|
|
|||
|
|
@ -406,22 +406,13 @@ internal class WalletViewModel @Inject constructor(
|
|||
router.openOnboardingScreen()
|
||||
}
|
||||
|
||||
override fun onMultiWalletSignedHashesNotificationClick() {
|
||||
override fun onSignedHashesNotificationCloseClick() {
|
||||
val state = uiState as? WalletState.ContentState ?: return
|
||||
|
||||
uiState = stateFactory.getStateAndTriggerEvent(
|
||||
state = uiState,
|
||||
event = WalletEvent.ShowWalletAlreadySignedHashesMessage(
|
||||
onUnderstandClick = {
|
||||
viewModelScope.launch(dispatchers.main) {
|
||||
setCardWasScannedUseCase(
|
||||
cardId = getWallet(index = state.walletsListConfig.selectedWalletIndex).cardId,
|
||||
)
|
||||
}
|
||||
},
|
||||
),
|
||||
setUiState = { uiState = it },
|
||||
)
|
||||
viewModelScope.launch(dispatchers.main) {
|
||||
setCardWasScannedUseCase(
|
||||
cardId = getWallet(index = state.walletsListConfig.selectedWalletIndex).cardId,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLikeAppClick() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue