Updated on 2026-08-14

This commit is contained in:
Tangem 2023-10-04 13:39:06 +03:00
parent 21d70dce7c
commit 26c2805f43
5 changed files with 31 additions and 18 deletions

View file

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

View file

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

View file

@ -17,6 +17,8 @@ internal interface WalletClickIntents {
fun onBackupCardClick()
fun onSignedHashesNotificationCloseClick()
fun onLikeAppClick()
fun onDislikeAppClick()

View file

@ -149,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,
),
)
}
}
@ -171,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 {

View file

@ -406,6 +406,15 @@ internal class WalletViewModel @Inject constructor(
router.openOnboardingScreen()
}
override fun onSignedHashesNotificationCloseClick() {
val state = uiState as? WalletState.ContentState ?: return
viewModelScope.launch(dispatchers.main) {
setCardWasScannedUseCase(
cardId = getWallet(index = state.walletsListConfig.selectedWalletIndex).cardId,
)
}
}
override fun onLikeAppClick() {
analyticsEventsHandler.send(WalletScreenAnalyticsEvent.NoticeRateAppButton(AnalyticsParam.RateApp.Liked))
uiState = stateFactory.getStateAndTriggerEvent(