snort/packages/app/src/Element/Event/Note.tsx

69 lines
2.2 KiB
TypeScript
Raw Normal View History

2022-12-18 14:51:47 +00:00
import "./Note.css";
import React from "react";
import { EventKind, TaggedNostrEvent } from "@snort/system";
2023-09-28 09:26:10 +00:00
import { NostrFileElement } from "Element/Event/NostrFileHeader";
2023-09-28 09:20:39 +00:00
import ZapstrEmbed from "Element/Embed/ZapstrEmbed";
2023-09-28 09:26:10 +00:00
import PubkeyList from "Element/Embed/PubkeyList";
2023-06-17 11:53:38 +00:00
import { LiveEvent } from "Element/LiveEvent";
2023-09-28 09:26:10 +00:00
import { ZapGoal } from "Element/Event/ZapGoal";
import NoteReaction from "Element/Event/NoteReaction";
import ProfilePreview from "Element/User/ProfilePreview";
import { NoteInner } from "./NoteInner";
2023-10-11 10:44:53 +00:00
import { LongFormText } from "./LongFormText";
2023-02-08 21:10:26 +00:00
2023-01-16 17:48:25 +00:00
export interface NoteProps {
2023-08-17 18:54:14 +00:00
data: TaggedNostrEvent;
className?: string;
2023-08-17 18:54:14 +00:00
related: readonly TaggedNostrEvent[];
highlight?: boolean;
ignoreModeration?: boolean;
2023-08-17 18:54:14 +00:00
onClick?: (e: TaggedNostrEvent) => void;
2023-04-18 21:20:13 +00:00
depth?: number;
2023-08-30 10:44:42 +00:00
searchedValue?: string;
2023-01-31 11:52:55 +00:00
options?: {
showHeader?: boolean;
2023-08-23 12:19:48 +00:00
showContextMenu?: boolean;
showTime?: boolean;
showPinned?: boolean;
showBookmarked?: boolean;
showFooter?: boolean;
2023-02-12 12:31:48 +00:00
showReactionsLink?: boolean;
2023-08-23 12:19:48 +00:00
showMedia?: boolean;
canUnpin?: boolean;
canUnbookmark?: boolean;
2023-03-31 22:43:07 +00:00
canClick?: boolean;
2023-09-25 12:59:31 +00:00
showMediaSpotlight?: boolean;
2023-10-11 10:44:53 +00:00
longFormPreview?: boolean;
};
2023-01-16 17:48:25 +00:00
}
export default function Note(props: NoteProps) {
2023-09-05 13:57:50 +00:00
const { data: ev, className } = props;
if (ev.kind === EventKind.Repost) {
return <NoteReaction data={ev} key={ev.id} root={undefined} depth={(props.depth ?? 0) + 1} />;
}
if (ev.kind === EventKind.FileHeader) {
return <NostrFileElement ev={ev} />;
}
2023-05-22 10:32:12 +00:00
if (ev.kind === EventKind.ZapstrTrack) {
2023-05-15 12:52:29 +00:00
return <ZapstrEmbed ev={ev} />;
}
2023-10-12 14:54:46 +00:00
if (ev.kind === EventKind.PubkeyLists || ev.kind === EventKind.ContactList) {
2023-05-22 10:32:12 +00:00
return <PubkeyList ev={ev} className={className} />;
}
2023-06-17 11:53:38 +00:00
if (ev.kind === EventKind.LiveEvent) {
return <LiveEvent ev={ev} />;
}
2023-09-05 13:57:50 +00:00
if (ev.kind === EventKind.SetMetadata) {
return <ProfilePreview actions={<></>} pubkey={ev.pubkey} className="card" />;
}
2023-08-20 21:51:56 +00:00
if (ev.kind === (9041 as EventKind)) {
return <ZapGoal ev={ev} />;
}
2023-10-11 10:44:53 +00:00
if (ev.kind === EventKind.LongFormTextNote) {
return <LongFormText ev={ev} related={props.related} isPreview={props.options?.longFormPreview ?? false} />;
}
2023-05-22 10:32:12 +00:00
2023-09-05 13:59:44 +00:00
return <NoteInner {...props} />;
2023-09-05 13:57:50 +00:00
}