Skip to content

Commit

Permalink
Show error on failed zap
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Staab committed Nov 22, 2024
1 parent 28810e7 commit 81ae83d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/app/views/Zap.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import {ctx, now, tryCatch, fetchJson} from "@welshman/lib"
import {createEvent} from "@welshman/util"
import {Nip01Signer} from "@welshman/signer"
import {signer, profilesByPubkey, zappersByLnurl} from "@welshman/app"
import {signer, profilesByPubkey, displayProfileByPubkey, zappersByLnurl} from "@welshman/app"
import Anchor from "src/partials/Anchor.svelte"
import FieldInline from "src/partials/FieldInline.svelte"
import Toggle from "src/partials/Toggle.svelte"
Expand Down Expand Up @@ -99,7 +99,7 @@
const qs = `?amount=${msats}&nostr=${zapString}&lnurl=${zapper.lnurl}`
const res = await tryCatch(() => fetchJson(zapper.callback + qs))
return {...zap, invoice: res?.pr}
return {...zap, invoice: res?.pr, error: res?.reason}
}),
)
Expand All @@ -113,8 +113,13 @@
// Close the router once we can show the next modal
router.pop()
for (const {invoice, relays, zapper, pubkey} of preppedZaps) {
for (const {invoice, error, relays, zapper, pubkey} of preppedZaps) {
if (!invoice) {
const profileDisplay = displayProfileByPubkey(pubkey)
const message = error || "no error given"
alert(`Failed to get an invoice for ${profileDisplay}: ${message}`)
continue
}
Expand Down

0 comments on commit 81ae83d

Please sign in to comment.