[#1429] Deduplicate messages on transaction

- Closes #1429
- Changelog update
This commit is contained in:
Honza Rychnovský 2024-05-02 12:53:21 +02:00 committed by GitHub
parent 448177c2d1
commit e2ddebe47c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View File

@ -11,7 +11,8 @@ directly impact users rather than highlighting other key architectural updates.*
### Added
- Delete Zashi feature has been added. It's accessible from the Advanced settings screen. It removes the wallet
secrets from Zashi and resets its state.
secrets from Zashi and resets its state.
- Transaction messages are now checked and removed in case of duplicity
### Changed
- We've improved the visibility logic of the little loader that is part of the Balances widget

View File

@ -545,8 +545,13 @@ private fun HistoryItemExpandedPart(
) {
Column(modifier = modifier) {
if (transaction.messages.containsValidMemo()) {
// Filter out identical messages on a multi-messages transaction that could be created, e.g., using
// YWallet, which tends to balance orchard and sapling pools, including by splitting a payment equally
// across both pools.
val uniqueMessages = transaction.messages!!.deduplicateMemos()
HistoryItemMessagePart(
messages = transaction.messages!!.toPersistentList(),
messages = uniqueMessages.toPersistentList(),
state = transaction.overview.getExtendedState(),
onAction = onAction
)
@ -592,6 +597,10 @@ private fun List<String>?.containsValidMemo(): Boolean {
return !isNullOrEmpty() && find { it.isNotEmpty() } != null
}
private fun List<String>.deduplicateMemos(): List<String> {
return distinct()
}
const val EXPANDED_TRANSACTION_ID_WIDTH_RATIO = 0.75f
const val COLLAPSED_TRANSACTION_ID_WIDTH_RATIO = 0.5f