feat: render kind 1 reposts
This commit is contained in:
@ -21,6 +21,7 @@ import { setPinned, setBookmarked } from "State/Login";
|
|||||||
import type { RootState } from "State/Store";
|
import type { RootState } from "State/Store";
|
||||||
|
|
||||||
import messages from "./messages";
|
import messages from "./messages";
|
||||||
|
import NoteReaction from "./NoteReaction";
|
||||||
|
|
||||||
export interface NoteProps {
|
export interface NoteProps {
|
||||||
data?: TaggedRawEvent;
|
data?: TaggedRawEvent;
|
||||||
@ -65,6 +66,12 @@ export default function Note(props: NoteProps) {
|
|||||||
const { data, related, highlight, options: opt, ["data-ev"]: parsedEvent, ignoreModeration = false } = props;
|
const { data, related, highlight, options: opt, ["data-ev"]: parsedEvent, ignoreModeration = false } = props;
|
||||||
const [showReactions, setShowReactions] = useState(false);
|
const [showReactions, setShowReactions] = useState(false);
|
||||||
const ev = useMemo(() => parsedEvent ?? new NEvent(data), [data]);
|
const ev = useMemo(() => parsedEvent ?? new NEvent(data), [data]);
|
||||||
|
if (
|
||||||
|
ev.Kind === EventKind.TextNote &&
|
||||||
|
ev.Tags.some((a, i) => a.Key === "e" && a.Marker === "mention" && ev.Content === `#[${i}]`)
|
||||||
|
) {
|
||||||
|
return <NoteReaction data={data} key={data.id} />;
|
||||||
|
}
|
||||||
const pubKeys = useMemo(() => ev.Thread?.PubKeys || [], [ev]);
|
const pubKeys = useMemo(() => ev.Thread?.PubKeys || [], [ev]);
|
||||||
const users = useUserProfiles(pubKeys);
|
const users = useUserProfiles(pubKeys);
|
||||||
const deletions = useMemo(() => getReactions(related, ev.Id, EventKind.Deletion), [related]);
|
const deletions = useMemo(() => getReactions(related, ev.Id, EventKind.Deletion), [related]);
|
||||||
@ -98,7 +105,16 @@ export default function Note(props: NoteProps) {
|
|||||||
}, [reactions]);
|
}, [reactions]);
|
||||||
const positive = groupReactions[Reaction.Positive];
|
const positive = groupReactions[Reaction.Positive];
|
||||||
const negative = groupReactions[Reaction.Negative];
|
const negative = groupReactions[Reaction.Negative];
|
||||||
const reposts = useMemo(() => dedupeByPubkey(getReactions(related, ev.Id, EventKind.Repost)), [related, ev]);
|
const reposts = useMemo(
|
||||||
|
() =>
|
||||||
|
dedupeByPubkey([
|
||||||
|
...getReactions(related, ev.Id, EventKind.TextNote).filter(e =>
|
||||||
|
e.tags.some((a, i) => a[0] === "e" && a[1] === ev.Id && a[3] === "mention" && e.content === `#[${i}]`)
|
||||||
|
),
|
||||||
|
...getReactions(related, ev.Id, EventKind.Repost),
|
||||||
|
]),
|
||||||
|
[related, ev]
|
||||||
|
);
|
||||||
const zaps = useMemo(() => {
|
const zaps = useMemo(() => {
|
||||||
const sortedZaps = getReactions(related, ev.Id, EventKind.ZapReceipt)
|
const sortedZaps = getReactions(related, ev.Id, EventKind.ZapReceipt)
|
||||||
.map(parseZap)
|
.map(parseZap)
|
||||||
|
@ -30,7 +30,12 @@ export default function NoteReaction(props: NoteReactionProps) {
|
|||||||
return null;
|
return null;
|
||||||
}, [ev]);
|
}, [ev]);
|
||||||
|
|
||||||
if (ev.Kind !== EventKind.Reaction && ev.Kind !== EventKind.Repost) {
|
if (
|
||||||
|
ev.Kind !== EventKind.Reaction &&
|
||||||
|
ev.Kind !== EventKind.Repost &&
|
||||||
|
(ev.Kind !== EventKind.TextNote ||
|
||||||
|
ev.Tags.every((a, i) => a.Event !== refEvent || a.Marker !== "mention" || ev.Content !== `#[${i}]`))
|
||||||
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +57,7 @@ export default function NoteReaction(props: NoteReactionProps) {
|
|||||||
const root = extractRoot();
|
const root = extractRoot();
|
||||||
const isOpMuted = root && isMuted(root.pubkey);
|
const isOpMuted = root && isMuted(root.pubkey);
|
||||||
const opt = {
|
const opt = {
|
||||||
showHeader: ev?.Kind === EventKind.Repost,
|
showHeader: ev?.Kind === EventKind.Repost || ev?.Kind === EventKind.TextNote,
|
||||||
showFooter: false,
|
showFooter: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user