From 44b29b777d96e9418dd32cba33342b9515cbddf2 Mon Sep 17 00:00:00 2001 From: Kieran Date: Fri, 24 Feb 2023 23:03:01 +0000 Subject: [PATCH] feat: default zap amount --- packages/app/src/Element/SendSats.tsx | 9 ++++++--- packages/app/src/Pages/settings/Preferences.tsx | 15 +++++++++++++++ packages/app/src/State/Login.ts | 6 ++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/app/src/Element/SendSats.tsx b/packages/app/src/Element/SendSats.tsx index 4707a87..f27e761 100644 --- a/packages/app/src/Element/SendSats.tsx +++ b/packages/app/src/Element/SendSats.tsx @@ -1,10 +1,12 @@ import "./SendSats.css"; import { useEffect, useMemo, useState } from "react"; import { useIntl, FormattedMessage } from "react-intl"; +import { useSelector } from "react-redux"; import { formatShort } from "Number"; import { bech32ToText } from "Util"; import { HexKey, Tag } from "@snort/nostr"; +import { RootState } from "State/Store"; import Check from "Icons/Check"; import Zap from "Icons/Zap"; import Close from "Icons/Close"; @@ -72,7 +74,8 @@ export default function LNURLTip(props: LNURLTipProps) { const service = props.svc; const show = props.show || false; const { note, author, target } = props; - const amounts = [500, 1_000, 5_000, 10_000, 20_000, 50_000, 100_000, 1_000_000]; + const defaultZapAmount = useSelector((s: RootState) => s.login.preferences.defaultZapAmount); + const amounts = [defaultZapAmount, 1_000, 5_000, 10_000, 20_000, 50_000, 100_000, 1_000_000]; const emojis: Record = { 1_000: "👍", 5_000: "💜", @@ -83,7 +86,7 @@ export default function LNURLTip(props: LNURLTipProps) { 1_000_000: "🤯", }; const [payService, setPayService] = useState(); - const [amount, setAmount] = useState(500); + const [amount, setAmount] = useState(defaultZapAmount); const [customAmount, setCustomAmount] = useState(); const [invoice, setInvoice] = useState(); const [comment, setComment] = useState(); @@ -104,7 +107,7 @@ export default function LNURLTip(props: LNURLTipProps) { setPayService(undefined); setError(undefined); setInvoice(props.invoice ? { pr: props.invoice } : undefined); - setAmount(500); + setAmount(defaultZapAmount); setComment(undefined); setSuccess(undefined); setZapType(ZapType.PublicZap); diff --git a/packages/app/src/Pages/settings/Preferences.tsx b/packages/app/src/Pages/settings/Preferences.tsx index ba75770..90c0537 100644 --- a/packages/app/src/Pages/settings/Preferences.tsx +++ b/packages/app/src/Pages/settings/Preferences.tsx @@ -111,6 +111,21 @@ const PreferencesPage = () => { +
+
+
+ +
+
+
+ dispatch(setPreferences({ ...perf, defaultZapAmount: parseInt(e.target.value) }))} + /> +
+
diff --git a/packages/app/src/State/Login.ts b/packages/app/src/State/Login.ts index 6cc76e0..1458760 100644 --- a/packages/app/src/State/Login.ts +++ b/packages/app/src/State/Login.ts @@ -70,6 +70,11 @@ export interface UserPreferences { * Default page to select on load */ defaultRootTab: "posts" | "conversations" | "global"; + + /** + * Default zap amount + */ + defaultZapAmount: number; } export type DbType = "indexdDb" | "redux"; @@ -231,6 +236,7 @@ export const InitState = { fileUploader: "void.cat", imgProxyConfig: DefaultImgProxy, defaultRootTab: "posts", + defaultZapAmount: 500, }, } as LoginStore;