mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-10-05 19:28:25 +00:00
fix(zap settings): de-dupe preset amounts so drag-reorder + chip keys stay valid
addAmount() allowed adding the same amount twice; two preset chips then share the same key(amount) (Compose duplicate-key hazard) and the drag-reorder's indexOf(amount) resolves to the wrong chip. De-dupe on add. https://claude.ai/code/session_01HNE2z7CSYZ2G8KwC5fziJn
This commit is contained in:
+4
-1
@@ -72,7 +72,10 @@ class UpdateZapAmountViewModel : ViewModel() {
|
||||
|
||||
fun addAmount() {
|
||||
val newValue = nextAmount.text.trim().toLongOrNull()
|
||||
if (newValue != null) {
|
||||
// De-dupe: a repeated amount would give two preset chips the same key (a
|
||||
// Compose duplicate-key hazard) and make the drag-reorder's indexOf()
|
||||
// resolve to the wrong chip.
|
||||
if (newValue != null && newValue !in amountSet) {
|
||||
amountSet = amountSet + newValue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user