note content rendering fix

This commit is contained in:
Martti Malmi 2023-12-18 13:24:04 +02:00
parent e2e3c9e638
commit 63b3ad2d57

View File

@ -45,29 +45,32 @@ export interface NoteProps {
export default function Note(props: NoteProps) { export default function Note(props: NoteProps) {
const { data: ev, className } = props; const { data: ev, className } = props;
let content; let content;
if (ev.kind === EventKind.Repost) { switch (ev.kind) {
case EventKind.Repost:
content = <NoteReaction data={ev} key={ev.id} root={undefined} depth={(props.depth ?? 0) + 1} />; content = <NoteReaction data={ev} key={ev.id} root={undefined} depth={(props.depth ?? 0) + 1} />;
} break;
if (ev.kind === EventKind.FileHeader) { case EventKind.FileHeader:
content = <NostrFileElement ev={ev} />; content = <NostrFileElement ev={ev} />;
} break;
if (ev.kind === EventKind.ZapstrTrack) { case EventKind.ZapstrTrack:
content = <ZapstrEmbed ev={ev} />; content = <ZapstrEmbed ev={ev} />;
} break;
if (ev.kind === EventKind.FollowSet || ev.kind === EventKind.ContactList) { case EventKind.FollowSet:
case EventKind.ContactList:
content = <PubkeyList ev={ev} className={className} />; content = <PubkeyList ev={ev} className={className} />;
} break;
if (ev.kind === EventKind.LiveEvent) { case EventKind.LiveEvent:
content = <LiveEvent ev={ev} />; content = <LiveEvent ev={ev} />;
} break;
if (ev.kind === EventKind.SetMetadata) { case EventKind.SetMetadata:
content = <ProfilePreview actions={<></>} pubkey={ev.pubkey} />; content = <ProfilePreview actions={<></>} pubkey={ev.pubkey} />;
} break;
if (ev.kind === (9041 as EventKind)) { case 9041: // Assuming 9041 is a valid EventKind
content = <ZapGoal ev={ev} />; content = <ZapGoal ev={ev} />;
} break;
if (ev.kind === EventKind.LongFormTextNote) { case EventKind.LongFormTextNote:
content = ( content = (
<LongFormText <LongFormText
ev={ev} ev={ev}
@ -77,8 +80,10 @@ export default function Note(props: NoteProps) {
truncate={props.options?.truncate} truncate={props.options?.truncate}
/> />
); );
break;
default:
content = <NoteInner {...props} />;
} }
content = <NoteInner {...props} />;
return <ErrorBoundary>{content}</ErrorBoundary>; return <ErrorBoundary>{content}</ErrorBoundary>;
} }