Show correct reaction note

This commit is contained in:
Kieran 2023-01-02 22:54:03 +00:00
parent 96ec28d1e0
commit 3c87a12eab
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941

View File

@ -3,6 +3,7 @@ import { useDispatch, useSelector } from "react-redux"
import Note from "../element/Note"; import Note from "../element/Note";
import NoteReaction from "../element/NoteReaction"; import NoteReaction from "../element/NoteReaction";
import useSubscription from "../feed/Subscription"; import useSubscription from "../feed/Subscription";
import Event from "../nostr/Event";
import EventKind from "../nostr/EventKind"; import EventKind from "../nostr/EventKind";
import { Subscriptions } from "../nostr/Subscriptions"; import { Subscriptions } from "../nostr/Subscriptions";
import { markNotificationsRead } from "../state/Login"; import { markNotificationsRead } from "../state/Login";
@ -17,7 +18,11 @@ export default function NotificationsPage() {
const etagged = useMemo(() => { const etagged = useMemo(() => {
return notifications?.filter(a => a.kind === EventKind.Reaction) return notifications?.filter(a => a.kind === EventKind.Reaction)
.map(a => a.tags.filter(b => b[0] === "e")[0][1]) .map(a => {
let ev = Event.FromObject(a);
let thread = ev.GetThread();
return thread?.ReplyTo?.Event ?? thread?.Root?.Event;
})
}, [notifications]); }, [notifications]);
const subEvents = useMemo(() => { const subEvents = useMemo(() => {
@ -46,7 +51,9 @@ export default function NotificationsPage() {
let reactions = otherNotes?.notes?.filter(c => c.tags.find(b => b[0] === "e" && b[1] === a.id)); let reactions = otherNotes?.notes?.filter(c => c.tags.find(b => b[0] === "e" && b[1] === a.id));
return <Note data={a} key={a.id} reactions={reactions} /> return <Note data={a} key={a.id} reactions={reactions} />
} else if (a.kind === EventKind.Reaction) { } else if (a.kind === EventKind.Reaction) {
let reactedTo = a.tags.filter(a => a[0] === "e")[0][1]; let ev = Event.FromObject(a);
let thread = ev.GetThread();
let reactedTo = thread?.ReplyTo?.Event ?? thread?.Root?.Event;
let reactedNote = otherNotes?.notes?.find(c => c.id === reactedTo); let reactedNote = otherNotes?.notes?.find(c => c.id === reactedTo);
return <NoteReaction data={a} key={a.id} root={reactedNote} /> return <NoteReaction data={a} key={a.id} root={reactedNote} />
} }