cancel fast zap
This commit is contained in:
parent
17c6b65158
commit
7463196edf
@ -21,7 +21,7 @@ import Zap from "Icons/Zap";
|
|||||||
import Reply from "Icons/Reply";
|
import Reply from "Icons/Reply";
|
||||||
import { formatShort } from "Number";
|
import { formatShort } from "Number";
|
||||||
import useEventPublisher from "Feed/EventPublisher";
|
import useEventPublisher from "Feed/EventPublisher";
|
||||||
import { hexToBech32, normalizeReaction } from "Util";
|
import { hexToBech32, normalizeReaction, unwrap } from "Util";
|
||||||
import { NoteCreator } from "Element/NoteCreator";
|
import { NoteCreator } from "Element/NoteCreator";
|
||||||
import Reactions from "Element/Reactions";
|
import Reactions from "Element/Reactions";
|
||||||
import SendSats from "Element/SendSats";
|
import SendSats from "Element/SendSats";
|
||||||
@ -127,15 +127,14 @@ export default function NoteFooter(props: NoteFooterProps) {
|
|||||||
try {
|
try {
|
||||||
const handler = new LNURL(lnurl);
|
const handler = new LNURL(lnurl);
|
||||||
await handler.load();
|
await handler.load();
|
||||||
|
const zap = handler.canZap ? await publisher.zap(prefs.defaultZapAmount * 1000, ev.PubKey, ev.Id) : undefined;
|
||||||
const zap = await publisher.zap(prefs.defaultZapAmount * 1000, ev.PubKey, ev.Id);
|
|
||||||
const invoice = await handler.getInvoice(prefs.defaultZapAmount, undefined, zap);
|
const invoice = await handler.getInvoice(prefs.defaultZapAmount, undefined, zap);
|
||||||
if (invoice.pr) {
|
await await webln.sendPayment(unwrap(invoice.pr));
|
||||||
await webln.sendPayment(invoice.pr);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("Instant zap failed", e);
|
console.warn("Fast zap failed", e);
|
||||||
setTip(true);
|
if (!(e instanceof Error) || e.message !== "User rejected") {
|
||||||
|
setTip(true);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
setZapping(false);
|
setZapping(false);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
|
|
||||||
|
interface WebLNPaymentResponse {
|
||||||
|
paymentHash: string;
|
||||||
|
preimage: string;
|
||||||
|
route: {
|
||||||
|
total_amt: number;
|
||||||
|
total_fees: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
webln?: {
|
webln?: {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
enable: () => Promise<void>;
|
enable: () => Promise<void>;
|
||||||
sendPayment: (pr: string) => Promise<unknown>;
|
sendPayment: (pr: string) => Promise<WebLNPaymentResponse>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user