From 0b288c921ed87128457685e4564b9aab0b774d6c Mon Sep 17 00:00:00 2001 From: Terry Yiu Date: Sat, 23 Aug 2025 10:42:10 -0400 Subject: [PATCH] Reduce default zap amount and deduplicate from preset zap amount items Changelog-Changed: Reduced default zap amount and deduplicated from preset zap amount items Closes: https://github.com/damus-io/damus/issues/3198 Signed-off-by: Terry Yiu --- .../Settings/Models/UserSettingsStore.swift | 2 +- .../Zaps/Views/CustomizeZapView.swift | 32 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/damus/Features/Settings/Models/UserSettingsStore.swift b/damus/Features/Settings/Models/UserSettingsStore.swift index dd1ee1b4..0da7377c 100644 --- a/damus/Features/Settings/Models/UserSettingsStore.swift +++ b/damus/Features/Settings/Models/UserSettingsStore.swift @@ -8,7 +8,7 @@ import Foundation import UIKit -let fallback_zap_amount = 1000 +let fallback_zap_amount = 21 let default_emoji_reactions = ["🤣", "🤙", "⚡", "💜", "🔥", "😀", "😃", "😄", "🥶"] func setting_property_key(key: String) -> String { diff --git a/damus/Features/Zaps/Views/CustomizeZapView.swift b/damus/Features/Zaps/Views/CustomizeZapView.swift index 703152c8..d7a7502d 100644 --- a/damus/Features/Zaps/Views/CustomizeZapView.swift +++ b/damus/Features/Zaps/Views/CustomizeZapView.swift @@ -8,6 +8,17 @@ import SwiftUI import Combine +let zapAmounts: [Int: String] = [ + 69: "😘", + 420: "🌿", + 5000: "💜", + 10_000: "😍", + 20_000: "🤩", + 50_000: "🔥", + 100_000: "🚀", + 1_000_000: "🤯", +] + struct ZapAmountItem: Identifiable, Hashable { let amount: Int let icon: String @@ -22,19 +33,14 @@ func get_default_zap_amount_item(_ def: Int) -> ZapAmountItem { } func get_zap_amount_items(_ default_zap_amt: Int) -> [ZapAmountItem] { - let def_item = get_default_zap_amount_item(default_zap_amt) - var entries = [ - ZapAmountItem(amount: 69, icon: "😘"), - ZapAmountItem(amount: 420, icon: "🌿"), - ZapAmountItem(amount: 5000, icon: "💜"), - ZapAmountItem(amount: 10_000, icon: "😍"), - ZapAmountItem(amount: 20_000, icon: "🤩"), - ZapAmountItem(amount: 50_000, icon: "🔥"), - ZapAmountItem(amount: 100_000, icon: "🚀"), - ZapAmountItem(amount: 1_000_000, icon: "🤯"), - ] - entries.append(def_item) - + var entries = zapAmounts.map { ZapAmountItem(amount: $0.key, icon: $0.value) } + + // Add default zap amount to the list only if it is not one of the preset entries so that it is not duplicated. + if zapAmounts[default_zap_amt] == nil { + let def_item = get_default_zap_amount_item(default_zap_amt) + entries.append(def_item) + } + entries.sort { $0.amount < $1.amount } return entries }