Align Android history handling with iOS and bump app version
This commit is contained in:
@ -44,6 +44,18 @@ data class TransactionItem(
|
||||
append(locationName)
|
||||
}
|
||||
}
|
||||
|
||||
fun historyKey(): String = buildString {
|
||||
append(date.time / 1000)
|
||||
append('|')
|
||||
append(amount)
|
||||
append('|')
|
||||
append(if (isCredit) 1 else 0)
|
||||
append('|')
|
||||
append(locationName.trim())
|
||||
append('|')
|
||||
append(title)
|
||||
}
|
||||
}
|
||||
|
||||
data class EmoneyUiState(
|
||||
@ -63,6 +75,16 @@ data class EmoneyUiState(
|
||||
}
|
||||
|
||||
fun hasCardData(): Boolean = cardType != CardType.UNKNOWN || cardNumber.isNotBlank() || balance > 0 || transactions.isNotEmpty()
|
||||
|
||||
fun clearingHistory(scanMessage: String): EmoneyUiState = copy(
|
||||
transactions = emptyList(),
|
||||
scanMessage = scanMessage
|
||||
)
|
||||
|
||||
fun deduplicatingHistory(): EmoneyUiState {
|
||||
val deduplicated = transactions.distinctBy { it.historyKey() }
|
||||
return if (deduplicated.size == transactions.size) this else copy(transactions = deduplicated)
|
||||
}
|
||||
}
|
||||
|
||||
fun String.formatCardNumber(): String {
|
||||
|
||||
Reference in New Issue
Block a user