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
This commit is contained in:
Claude
2026-01-17 19:10:00 +00:00
parent e7ab643538
commit 616cc083ce
4 changed files with 11 additions and 17 deletions

View File

@@ -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;

View File

@@ -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(() => {

View File

@@ -174,12 +174,7 @@ export function WindowRenderer({ window, onClose }: WindowRendererProps) {
content = <EventDetailViewer pointer={window.props.pointer} />;
break;
case "thread":
content = (
<ThreadViewer
pointer={window.props.pointer}
customTitle={window.customTitle}
/>
);
content = <ThreadViewer pointer={window.props.pointer} />;
break;
case "profile":
content = <ProfileViewer pubkey={window.props.pubkey} />;

View File

@@ -1 +1 @@
{"root":["./vite.config.ts"],"errors":true,"version":"5.9.3"}
{"root":["./vite.config.ts"],"version":"5.6.3"}