import { NDKEvent, NDKKind } from '@nostr-dev-kit/ndk'; import { useCallback } from 'react'; import { WVList } from 'virtua'; import { LoaderIcon } from '@shared/icons'; import { ChildNote, MemoizedArticleKind, MemoizedFileKind, MemoizedTextKind, NoteActions, NoteReplyForm, } from '@shared/notes'; import { ReplyList } from '@shared/notes/replies/list'; import { TitleBar } from '@shared/titleBar'; import { User } from '@shared/user'; import { WidgetWrapper } from '@shared/widgets'; import { useEvent } from '@utils/hooks/useEvent'; import { useNostr } from '@utils/hooks/useNostr'; import { Widget } from '@utils/types'; export function ThreadWidget({ widget }: { widget: Widget }) { const { isFetching, isError, data } = useEvent(widget.content); const { getEventThread } = useNostr(); const renderKind = useCallback( (event: NDKEvent) => { const thread = getEventThread(event.tags); switch (event.kind) { case NDKKind.Text: return ( <> {thread ? (
{thread.rootEventId ? ( ) : null} {thread.replyEventId ? : null}
) : null} ); case NDKKind.Article: return ; case 1063: return ; default: return null; } }, [data] ); return ( {isFetching ? (
) : ( <>
{isError ? (
Failed to fetch event
) : ( <> {renderKind(data)} )}
)}
); }