diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/Lnurlp.svelte | 9 | ||||
| -rw-r--r-- | src/routes/(app)/ln/[lnurl]/+page.svelte | 8 | ||||
| -rw-r--r-- | src/routes/(app)/send/lightning/[payreq]/[...memo]/+page.svelte | 11 |
3 files changed, 21 insertions, 7 deletions
diff --git a/src/components/Lnurlp.svelte b/src/components/Lnurlp.svelte index 2b715667..c1ae0c95 100644 --- a/src/components/Lnurlp.svelte +++ b/src/components/Lnurlp.svelte @@ -17,6 +17,8 @@ let amount = $state(Math.round(minSendable / 1000)), loading = $state(); let submit = () => (loading = true); + // An action result (an error, since success redirects) ends the wait + $effect(() => form && (loading = false)); </script> <div class="container px-4 mt-20 max-w-xl mx-auto space-y-2"> @@ -60,12 +62,15 @@ <div class="flex w-full gap-2"> {#if max >= Math.round(minSendable / 1000)} + <!-- loading is set by the form's onsubmit, not here: flipping + `disabled` from a click handler lands in the DOM before the + browser's submit activation runs, and a disabled button submits + nothing (the page just sat on a spinner). --> <button type="submit" class="btn !w-auto grow" formaction="?/max" - disabled={loading} - onclick={submit}>Max ⚡️{s(max)}</button + disabled={loading}>Max ⚡️{s(max)}</button > {/if} <button bind:this={send} type="submit" class="btn btn-accent !w-auto grow"> diff --git a/src/routes/(app)/ln/[lnurl]/+page.svelte b/src/routes/(app)/ln/[lnurl]/+page.svelte index 386df9d2..0f1b030f 100644 --- a/src/routes/(app)/ln/[lnurl]/+page.svelte +++ b/src/routes/(app)/ln/[lnurl]/+page.svelte @@ -1,12 +1,14 @@ <script> import Lnurlp from "$comp/Lnurlp.svelte"; import Lnurlw from "$comp/Lnurlw.svelte"; - let { data } = $props(); + let { data, form } = $props(); let { tag } = data; </script> +<!-- form carries the action result; without it a failed pay/max/withdraw + showed nothing and left the button spinning forever --> {#if tag === "payRequest"} - <Lnurlp {data} /> + <Lnurlp {data} {form} /> {:else if tag === "withdrawRequest"} - <Lnurlw {data} /> + <Lnurlw {data} {form} /> {/if} diff --git a/src/routes/(app)/send/lightning/[payreq]/[...memo]/+page.svelte b/src/routes/(app)/send/lightning/[payreq]/[...memo]/+page.svelte index c84e5d53..d3d9f757 100644 --- a/src/routes/(app)/send/lightning/[payreq]/[...memo]/+page.svelte +++ b/src/routes/(app)/send/lightning/[payreq]/[...memo]/+page.svelte @@ -174,7 +174,13 @@ {/if} </form> {:else} - <form method="POST" action="?/setAmount" class="space-y-2" use:enhance> + <form + method="POST" + action="?/setAmount" + class="space-y-2" + use:enhance + onsubmit={submit} + > <input type="hidden" value={a} name="amount" /> <input name="rate" value={$rate} type="hidden" /> @@ -187,12 +193,13 @@ /> <div class="flex justify-center gap-2"> + <!-- no onclick: see Lnurlp.svelte — disabling from the click + handler cancels the submit; the form's onsubmit sets loading --> <button type="submit" class="btn !w-auto grow" formaction="?/max" disabled={loading} - onclick={submit} > {#if loading} <Spinner /> |
