feat: render kind 1 reposts

This commit is contained in:
kPherox 2023-02-16 07:26:26 +09:00
parent 30d4d5f98b
commit 6ed1252eed
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D
2 changed files with 24 additions and 3 deletions

View File

@ -21,6 +21,7 @@ import { setPinned, setBookmarked } from "State/Login";
import type { RootState } from "State/Store";
import messages from "./messages";
import NoteReaction from "./NoteReaction";
export interface NoteProps {
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 [showReactions, setShowReactions] = useState(false);
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 users = useUserProfiles(pubKeys);
const deletions = useMemo(() => getReactions(related, ev.Id, EventKind.Deletion), [related]);
@ -98,7 +105,16 @@ export default function Note(props: NoteProps) {
}, [reactions]);
const positive = groupReactions[Reaction.Positive];
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 sortedZaps = getReactions(related, ev.Id, EventKind.ZapReceipt)
.map(parseZap)

View File

@ -30,7 +30,12 @@ export default function NoteReaction(props: NoteReactionProps) {
return null;
}, [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;
}
@ -52,7 +57,7 @@ export default function NoteReaction(props: NoteReactionProps) {
const root = extractRoot();
const isOpMuted = root && isMuted(root.pubkey);
const opt = {
showHeader: ev?.Kind === EventKind.Repost,
showHeader: ev?.Kind === EventKind.Repost || ev?.Kind === EventKind.TextNote,
showFooter: false,
};