diff --git a/src/components/ZapModal.svelte b/src/components/ZapModal.svelte index 68bb0b0..e32aaeb 100644 --- a/src/components/ZapModal.svelte +++ b/src/components/ZapModal.svelte @@ -31,25 +31,25 @@ // "pre" | "pending" | "success" | "error" $: state = "pre"; $: useQR = false; - + let error: Error; // TODO: add loading state while fetching invoice(s). async function submitNow(qr: boolean) { const a = await $ndk.zap(event, amount * 1000, message); a.on("complete", (results) => { - console.debug(results); - const allSuccessful = Array.from(results.values()).every(result => result !== undefined && !(result instanceof Error)); - state = allSuccessful ? "success" : (useQR ? "pending" : "error"); - + state = allSuccessful ? "success" : "error"; }); useQR = qr; - // try webln first. if (a) { + a.onCashuPay = () => { + error = new Error("Cannot Zap This User"); + return error; + }; try { state = "pending"; if (!qr) { @@ -64,7 +64,7 @@ paymentsToMakeQR.push(payment); paymentsToMakeQR = paymentsToMakeQR; - return undefined; // we don't have a preimage to return + return true; // we don't have a preimage to return }; } } catch (err) { @@ -80,17 +80,48 @@

Zap

-
+
{#if state == "pending"} +
+ Loading + + {useQR ? "Fetching Invoice(s)..." : "Waiting for Payment..."} + {#if useQR} + If this takes a while refresh and try again. + {/if} +
+ {:else if state == "pre"} +
+
+ {#if selectedCurrency == 'SATS'} + {#each defaultZapSatsAmounts as zapPamount} + (amount = zapPamount)} + /> + {/each} + {/if} +
+ +