feat: render zap dialog for lnurlp link

This commit is contained in:
2023-11-14 12:31:17 +00:00
parent a34ad5ff71
commit cdf2f12e80
3 changed files with 49 additions and 43 deletions

View File

@ -1,10 +1,12 @@
import { NostrLink, NostrPrefix, ParsedFragment, transformText, tryParseNostrLink } from "@snort/system";
import { FunctionComponent, useMemo } from "react";
import { Link } from "react-router-dom";
import { Emoji } from "./emoji";
import { Mention } from "./mention";
import { HyperText } from "./hypertext";
import { Event } from "./Event";
import { SendZapsDialog } from "./send-zap";
export type EventComponent = FunctionComponent<{ link: NostrLink }>;
@ -43,8 +45,17 @@ export function Text({ content, tags, eventComponent }: TextProps) {
}
case "mention":
return <Mention pubkey={f.content} />;
default:
default: {
if (f.content.startsWith("lnurlp:")) {
// LUD-17: https://github.com/lnurl/luds/blob/luds/17.md
const url = new URL(f.content);
url.protocol = "https:";
return <SendZapsDialog pubkey={undefined} lnurl={url.toString()} button={<Link to={""}>
{f.content}
</Link>} />
}
return <span className="text">{f.content}</span>;
}
}
}