fix: load event in DynamicWindowTitle to derive zap recipient

When opening a zap dialog via 'zap naddr1...' or 'zap nevent1...', the
window title was showing "ZAP" instead of "Zap {host name}" because
DynamicWindowTitle only had access to the empty recipientPubkey from
the initial props.

Now DynamicWindowTitle:
- Loads the event from eventPointer if present
- Derives the recipient using getSemanticAuthor() if recipientPubkey is empty
- Falls back to explicit recipientPubkey if provided

This ensures the window title shows the correct recipient name
immediately, matching the behavior in the ZapWindow component itself.
This commit is contained in:
Claude
2026-01-19 10:39:33 +00:00
parent 813ee13f20
commit d3ad918593

View File

@@ -447,8 +447,21 @@ function useDynamicTitle(window: WindowInstance): WindowTitleData {
const countHashtags =
appId === "count" && props.filter?.["#t"] ? props.filter["#t"] : [];
// Zap titles
const zapRecipientPubkey = appId === "zap" ? props.recipientPubkey : null;
// Zap titles - load event to derive recipient if needed
const zapEventPointer: EventPointer | AddressPointer | undefined =
appId === "zap" ? props.eventPointer : undefined;
const zapEvent = useNostrEvent(zapEventPointer);
// Derive recipient: use explicit pubkey or semantic author from event
const zapRecipientPubkey = useMemo(() => {
if (appId !== "zap") return null;
// If explicit recipient provided, use it
if (props.recipientPubkey) return props.recipientPubkey;
// Otherwise derive from event's semantic author
if (zapEvent) return getSemanticAuthor(zapEvent);
return null;
}, [appId, props.recipientPubkey, zapEvent]);
const zapRecipientProfile = useProfile(zapRecipientPubkey || "");
const zapTitle = useMemo(() => {
if (appId !== "zap" || !zapRecipientPubkey) return null;