From 93648085f972d6eb6b538d36827524b6c7ddece1 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 30 May 2026 02:16:39 +0000 Subject: [PATCH] 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 --- .../amethyst/ui/note/UpdateZapAmountViewModel.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountViewModel.kt index 76d97fa4c9..0a5931f26b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountViewModel.kt @@ -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 }