diff --git a/src/components/DynamicWindowTitle.tsx b/src/components/DynamicWindowTitle.tsx index 93b0220..2962cba 100644 --- a/src/components/DynamicWindowTitle.tsx +++ b/src/components/DynamicWindowTitle.tsx @@ -474,6 +474,23 @@ function useDynamicTitle(window: WindowInstance): WindowTitleData { const countHashtags = appId === "count" && props.filter?.["#t"] ? props.filter["#t"] : []; + // Zap titles + const zapRecipientPubkey = appId === "zap" ? props.recipientPubkey : null; + const zapRecipientProfile = useProfile(zapRecipientPubkey || ""); + const zapTitle = useMemo(() => { + if (appId !== "zap" || !zapRecipientPubkey) return null; + + if (zapRecipientProfile) { + const name = + zapRecipientProfile.display_name || + zapRecipientProfile.name || + `${zapRecipientPubkey.slice(0, 8)}...`; + return `Zap ${name}`; + } + + return `Zap ${zapRecipientPubkey.slice(0, 8)}...`; + }, [appId, zapRecipientPubkey, zapRecipientProfile]); + // REQ titles const reqTitle = useMemo(() => { if (appId !== "req") return null; @@ -783,7 +800,11 @@ function useDynamicTitle(window: WindowInstance): WindowTitleData { } // Priority order for title selection (dynamic titles based on data) - if (profileTitle) { + if (zapTitle) { + title = zapTitle; + icon = getCommandIcon("zap"); + tooltip = rawCommand; + } else if (profileTitle) { title = profileTitle; icon = getCommandIcon("profile"); tooltip = rawCommand; @@ -846,6 +867,10 @@ function useDynamicTitle(window: WindowInstance): WindowTitleData { title = chatTitle; icon = getCommandIcon("chat"); tooltip = rawCommand; + } else if (zapTitle) { + title = zapTitle; + icon = getCommandIcon("zap"); + tooltip = rawCommand; } else { title = staticTitle || appId.toUpperCase(); tooltip = rawCommand; @@ -857,6 +882,7 @@ function useDynamicTitle(window: WindowInstance): WindowTitleData { props, event, customTitle, + zapTitle, profileTitle, eventTitle, kindTitle, diff --git a/src/components/ZapWindow.tsx b/src/components/ZapWindow.tsx index 67b7c9e..08a7263 100644 --- a/src/components/ZapWindow.tsx +++ b/src/components/ZapWindow.tsx @@ -16,11 +16,11 @@ import { toast } from "sonner"; import { Zap, Wallet, - QrCode, Copy, ExternalLink, Loader2, CheckCircle2, + LogIn, } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; @@ -38,10 +38,11 @@ import { useProfile } from "@/hooks/useProfile"; import { use$ } from "applesauce-react/hooks"; import eventStore from "@/services/event-store"; import { useWallet } from "@/hooks/useWallet"; -import { getProfileContent } from "applesauce-core/helpers"; import { getDisplayName } from "@/lib/nostr-utils"; import { KindRenderer } from "./nostr/kinds"; import type { EventPointer, AddressPointer } from "@/lib/open-parser"; +import { useGrimoire } from "@/core/state"; +import accountManager from "@/services/accounts"; export interface ZapWindowProps { /** Recipient pubkey (who receives the zap) */ @@ -80,6 +81,10 @@ export function ZapWindow({ const recipientProfile = useProfile(recipientPubkey); + const { addWindow } = useGrimoire(); + const activeAccount = accountManager.active; + const canSign = !!activeAccount?.signer; + const { wallet, payInvoice, refreshBalance, getInfo } = useWallet(); // Fetch wallet info @@ -132,17 +137,6 @@ export function ZapWindow({ : recipientPubkey.slice(0, 8); }, [recipientPubkey, recipientProfile]); - // Get event author name if zapping an event - const eventAuthorName = useMemo(() => { - if (!event) return null; - const authorProfile = eventStore.getReplaceable(0, event.pubkey); - if (authorProfile) { - const content = getProfileContent(authorProfile); - return getDisplayName(event.pubkey, content); - } - return event.pubkey.slice(0, 8); - }, [event]); - // Track amount usage const trackAmountUsage = (amount: number) => { const newUsage = { @@ -327,26 +321,13 @@ export function ZapWindow({ window.open(`lightning:${invoice}`, "_blank"); }; + // Open account selector for login + const handleLogin = () => { + addWindow("conn", {}); + }; + return (
- For their{" "} - {event.kind === 1 ? "note" : `kind ${event.kind} event`} -
- )} -