diff options
| author | Adam Soltys <[email protected]> | 2024-11-25 22:13:04 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-11-25 22:13:04 -0800 |
| commit | 2761363d694d3f24600abbe656769f64d7a67605 (patch) | |
| tree | 8c2d2362f57060a62870909a8551686e605cd942 /src/routes | |
| parent | 6874ab9feb1e789c2c9b4c568b29aba9bb2190f6 (diff) | |
| download | coinos-ui-2761363d694d3f24600abbe656769f64d7a67605.tar.gz coinos-ui-2761363d694d3f24600abbe656769f64d7a67605.zip | |
fix amount prompt
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/(app)/[username]/receive/+page.svelte | 23 | ||||
| -rw-r--r-- | src/routes/(app)/invoice/[id]/+page.svelte | 11 |
2 files changed, 21 insertions, 13 deletions
diff --git a/src/routes/(app)/[username]/receive/+page.svelte b/src/routes/(app)/[username]/receive/+page.svelte index be4ed3d0..ddb17e71 100644 --- a/src/routes/(app)/[username]/receive/+page.svelte +++ b/src/routes/(app)/[username]/receive/+page.svelte @@ -16,10 +16,8 @@ let showOptions; - let { id, rates, subject, user, src, text } = $state(data); - let refresh = (data) => { - ({ id, rates, subject, user, src, text } = data); - }; + let { id, rates, subject, user, text } = $state(data); + let { src } = $derived(data); let { currency, username } = subject; let rate = rates[currency]; @@ -52,12 +50,17 @@ }); }; - let setAmount = async () => { - if (typeof $amountPrompt === "undefined") $amountPrompt = true; + let setAmount = async (e) => { + e.preventDefault(); + e.stopPropagation(); + settingAmount = false; + + if (typeof $amountPrompt === "undefined") $amountPrompt = true; amount = newAmount; invoice.amount = newAmount; invoice.tip = 0; + ({ id } = await post(`/invoice`, { invoice, user: { username, currency }, @@ -75,15 +78,16 @@ let fiat = $state(true); let toggleAmount = () => (settingAmount = !settingAmount); let submit; - run(() => { - refresh(data); - }); let link = $derived( [types.bitcoin, types.liquid].includes(type) ? text : `lightning:${text}`, ); let txt = $derived( [types.bitcoin, types.liquid].includes(type) ? hash : text, ); + + onMount(() => { + if ($amountPrompt && !amount) toggleAmount(); + }); </script> <div class="invoice container mx-auto max-w-xl px-4 space-y-2"> @@ -126,6 +130,5 @@ {settingAmount} {setAmount} {toggleAmount} - amountPrompt={$amountPrompt} t={$t} /> diff --git a/src/routes/(app)/invoice/[id]/+page.svelte b/src/routes/(app)/invoice/[id]/+page.svelte index 15dc97ae..8c6e2b75 100644 --- a/src/routes/(app)/invoice/[id]/+page.svelte +++ b/src/routes/(app)/invoice/[id]/+page.svelte @@ -65,11 +65,16 @@ goto(`./${id}?options=true`, { invalidateAll: true, noScroll: true }); }; - let setAmount = $state(async () => { - if (typeof $amountPrompt === "undefined") $amountPrompt = true; + let setAmount = async (e) => { + e.preventDefault(); + e.stopPropagation(); + settingAmount = false; + + if (typeof $amountPrompt === "undefined") $amountPrompt = true; invoice.amount = newAmount; invoice.tip = 0; + ({ id } = await post(`/invoice`, { invoice, user: { username, currency }, @@ -80,7 +85,7 @@ else url += "?options=true"; goto(url, { invalidateAll: true, noScroll: true }); - }); + }; let newAmount = $state(0); let settingAmount = $state(); |
