damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit f96ad99790554b899db0632437057324c14ab896
parent 1f79c209735e8aeec2d6b4e8c7349c8a6421f362
Author: William Casarin <jb55@jb55.com>
Date:   Mon,  6 Feb 2023 10:04:53 -0800

zaps: initial configuration for default zap amount

Diffstat:
Mdamus/Components/ZapButton.swift | 3++-
Mdamus/Models/UserSettingsStore.swift | 12++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/damus/Components/ZapButton.swift b/damus/Components/ZapButton.swift @@ -52,7 +52,8 @@ struct ZapButton: View { damus_state.lnurls.endpoints[target.pubkey] = payreq } - guard let inv = await fetch_zap_invoice(payreq, zapreq: zapreq, amount: 1000000) else { + let tip_amount = get_default_tip_amount(pubkey: damus_state.pubkey) + guard let inv = await fetch_zap_invoice(payreq, zapreq: zapreq, amount: tip_amount) else { DispatchQueue.main.async { zapping = false } diff --git a/damus/Models/UserSettingsStore.swift b/damus/Models/UserSettingsStore.swift @@ -12,6 +12,18 @@ func should_show_wallet_selector(_ pubkey: String) -> Bool { return UserDefaults.standard.object(forKey: "show_wallet_selector") as? Bool ?? true } +let tip_amount_key = "default_tip_amount" +func set_default_tip_amount(pubkey: String, amount: Int64) { + let key = "\(pubkey)_\(tip_amount_key)" + UserDefaults.standard.setValue(amount, forKey: key) +} + +func get_default_tip_amount(pubkey: String) -> Int64 { + let key = "\(pubkey)_\(tip_amount_key)" + return UserDefaults.standard.object(forKey: key) as? Int64 ?? 1000000 +} + + func get_default_wallet(_ pubkey: String) -> Wallet { if let defaultWalletName = UserDefaults.standard.string(forKey: "default_wallet"), let default_wallet = Wallet(rawValue: defaultWalletName)