Remove webln from state, simplify webln detection.

This commit is contained in:
Chad Curtis committed 2025-10-05 20:59:27 +00:00
1 parent 45cdcecf9e
commit b77885093c
4 files changed
+32 -38

No files matched your search

+8 -8
View File
@@ -68,7 +68,7 @@ AddWalletContent.displayName = 'AddWalletContent';
// Extracted WalletContent to prevent re-renders
const WalletContent = forwardRef<HTMLDivElement, {
hasWebLN: boolean;
webln: import('@webbtc/webln-types').WebLNProvider | null;
hasNWC: boolean;
connections: NWCConnection[];
connectionInfo: Record<string, NWCInfo>;
@@ -77,7 +77,7 @@ const WalletContent = forwardRef<HTMLDivElement, {
handleRemoveConnection: (cs: string) => void;
setAddDialogOpen: (open: boolean) => void;
}>(({
hasWebLN,
webln,
hasNWC,
connections,
connectionInfo,
@@ -101,9 +101,9 @@ const WalletContent = forwardRef<HTMLDivElement, {
</div>
</div>
<div className="flex items-center gap-2">
{hasWebLN && <CheckCircle className="h-4 w-4 text-green-600" />}
<Badge variant={hasWebLN ? "default" : "secondary"} className="text-xs">
{hasWebLN ? "Ready" : "Not Found"}
{webln && <CheckCircle className="h-4 w-4 text-green-600" />}
<Badge variant={webln ? "default" : "secondary"} className="text-xs">
{webln ? "Ready" : "Not Found"}
</Badge>
</div>
</div>
@@ -189,7 +189,7 @@ const WalletContent = forwardRef<HTMLDivElement, {
)}
</div>
{/* Help */}
{!hasWebLN && connections.length === 0 && (
{!webln && connections.length === 0 && (
<>
<Separator />
<div className="text-center py-4 space-y-2">
@@ -220,7 +220,7 @@ export function WalletModal({ children, className }: WalletModalProps) {
setActiveConnection
} = useNWC();
const { hasWebLN } = useWallet();
const { webln } = useWallet();
const hasNWC = connections.length > 0 && connections.some(c => c.isConnected);
const { toast } = useToast();
@@ -261,7 +261,7 @@ export function WalletModal({ children, className }: WalletModalProps) {
};
const walletContentProps = {
hasWebLN,
webln,
hasNWC,
connections,
connectionInfo,
+5 -5
View File
@@ -55,7 +55,7 @@ interface ZapContentProps {
isZapping: boolean;
qrCodeUrl: string;
copied: boolean;
hasWebLN: boolean;
webln: import('@webbtc/webln-types').WebLNProvider | null;
handleZap: () => void;
handleCopy: () => void;
openInWallet: () => void;
@@ -73,7 +73,7 @@ const ZapContent = forwardRef<HTMLDivElement, ZapContentProps>(({
isZapping,
qrCodeUrl,
copied,
hasWebLN,
webln,
handleZap,
handleCopy,
openInWallet,
@@ -138,7 +138,7 @@ const ZapContent = forwardRef<HTMLDivElement, ZapContentProps>(({
{/* Payment buttons */}
<div className="space-y-3 mt-4">
{hasWebLN && (
{webln && (
<Button
onClick={() => {
const finalAmount = typeof amount === 'string' ? parseInt(amount, 10) : amount;
@@ -239,7 +239,7 @@ export function ZapDialog({ target, children, className }: ZapDialogProps) {
const { user } = useCurrentUser();
const { data: author } = useAuthor(target.pubkey);
const { toast } = useToast();
const { webln, activeNWC, hasWebLN } = useWallet();
const { webln, activeNWC } = useWallet();
const { zap, isZapping, invoice, setInvoice } = useZaps(target, webln, activeNWC, () => setOpen(false));
const [amount, setAmount] = useState<number | string>(100);
const [comment, setComment] = useState<string>('');
@@ -337,7 +337,7 @@ export function ZapDialog({ target, children, className }: ZapDialogProps) {
isZapping,
qrCodeUrl,
copied,
hasWebLN,
webln,
handleZap,
handleCopy,
openInWallet,