From 616cc083ce0df59ac65da889e8f5e1a92fc69c0e Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 17 Jan 2026 19:10:00 +0000 Subject: [PATCH] fix: Resolve TypeScript errors in thread components - Handle undefined types from getCommentReplyPointer - Fix pointer type assertions for AddressPointer - Remove unused customTitle prop - Change null to undefined for useNostrEvent compatibility --- src/components/ThreadConversation.tsx | 2 +- src/components/ThreadViewer.tsx | 17 ++++++++--------- src/components/WindowRenderer.tsx | 7 +------ tsconfig.node.tsbuildinfo | 2 +- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/components/ThreadConversation.tsx b/src/components/ThreadConversation.tsx index 2a84a20..c7eb114 100644 --- a/src/components/ThreadConversation.tsx +++ b/src/components/ThreadConversation.tsx @@ -45,7 +45,7 @@ function getParentId( // Fallback: check if reply pointer gives us an event ID const pointer = getCommentReplyPointer(event); if (pointer && "id" in pointer) { - return pointer.id; + return pointer.id || null; } return null; diff --git a/src/components/ThreadViewer.tsx b/src/components/ThreadViewer.tsx index 2ed603e..264967a 100644 --- a/src/components/ThreadViewer.tsx +++ b/src/components/ThreadViewer.tsx @@ -26,7 +26,6 @@ import { ThreadConversation } from "./ThreadConversation"; export interface ThreadViewerProps { pointer: EventPointer | AddressPointer; - customTitle?: string; } /** @@ -74,12 +73,12 @@ function getThreadRoot( // Fallback to parent pointer if no root found if (pointer) { if ("id" in pointer) { - return { id: pointer.id }; - } else { + return pointer.id ? { id: pointer.id } : null; + } else if ("kind" in pointer && "pubkey" in pointer) { return { - kind: pointer.kind, - pubkey: pointer.pubkey, - identifier: pointer.identifier, + kind: pointer.kind as number, + pubkey: pointer.pubkey as string, + identifier: (pointer.identifier as string | undefined) || "", }; } } @@ -96,18 +95,18 @@ function getThreadRoot( * ThreadViewer - Displays a Nostr thread with root post and replies * Supports both NIP-10 (kind 1 replies) and NIP-22 (kind 1111 comments) */ -export function ThreadViewer({ pointer, customTitle }: ThreadViewerProps) { +export function ThreadViewer({ pointer }: ThreadViewerProps) { const event = useNostrEvent(pointer); const { relays: relayStates } = useRelayState(); // Get thread root const rootPointer = useMemo(() => { - if (!event) return null; + if (!event) return undefined; return getThreadRoot(event); }, [event]); // Load root event (might be the same as event) - const rootEvent = useNostrEvent(rootPointer); + const rootEvent = useNostrEvent(rootPointer ?? undefined); // Get relays for the root event const rootRelays = useMemo(() => { diff --git a/src/components/WindowRenderer.tsx b/src/components/WindowRenderer.tsx index bb58042..ae1364c 100644 --- a/src/components/WindowRenderer.tsx +++ b/src/components/WindowRenderer.tsx @@ -174,12 +174,7 @@ export function WindowRenderer({ window, onClose }: WindowRendererProps) { content = ; break; case "thread": - content = ( - - ); + content = ; break; case "profile": content = ; diff --git a/tsconfig.node.tsbuildinfo b/tsconfig.node.tsbuildinfo index 5e39d3d..75ea001 100644 --- a/tsconfig.node.tsbuildinfo +++ b/tsconfig.node.tsbuildinfo @@ -1 +1 @@ -{"root":["./vite.config.ts"],"errors":true,"version":"5.9.3"} \ No newline at end of file +{"root":["./vite.config.ts"],"version":"5.6.3"} \ No newline at end of file