mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-10 15:36:53 +02:00
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:
@@ -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;
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
@@ -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} />;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"root":["./vite.config.ts"],"errors":true,"version":"5.9.3"}
|
||||
{"root":["./vite.config.ts"],"version":"5.6.3"}
|
||||
Reference in New Issue
Block a user