feat: handle user cancellation in zap process
This commit is contained in:
parent
5e3cd04280
commit
094ccd92da
3 changed files with 14 additions and 5 deletions
|
|
@ -48,14 +48,18 @@ export default function ZapButton({ event }: { event: Event }) {
|
|||
throw new Error('You need to be logged in to zap')
|
||||
}
|
||||
setZapping(true)
|
||||
const { invoice } = await lightning.zap(
|
||||
const zapResult = await lightning.zap(
|
||||
pubkey,
|
||||
event.pubkey,
|
||||
defaultZapSats,
|
||||
defaultZapComment,
|
||||
event.id
|
||||
)
|
||||
addZap(event.id, invoice, defaultZapSats, defaultZapComment)
|
||||
// user canceled
|
||||
if (!zapResult) {
|
||||
return
|
||||
}
|
||||
addZap(event.id, zapResult.invoice, defaultZapSats, defaultZapComment)
|
||||
} catch (error) {
|
||||
toast({
|
||||
title: t('Zap failed'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue