diff --git a/src/pages/Notifications.js b/src/pages/Notifications.js index 40aa322..a997450 100644 --- a/src/pages/Notifications.js +++ b/src/pages/Notifications.js @@ -3,6 +3,7 @@ import { useDispatch, useSelector } from "react-redux" import Note from "../element/Note"; import NoteReaction from "../element/NoteReaction"; import useSubscription from "../feed/Subscription"; +import Event from "../nostr/Event"; import EventKind from "../nostr/EventKind"; import { Subscriptions } from "../nostr/Subscriptions"; import { markNotificationsRead } from "../state/Login"; @@ -17,7 +18,11 @@ export default function NotificationsPage() { const etagged = useMemo(() => { 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]); const subEvents = useMemo(() => { @@ -37,16 +42,18 @@ export default function NotificationsPage() { const sorted = [ ...notifications - ].sort((a,b) => b.created_at - a.created_at); + ].sort((a, b) => b.created_at - a.created_at); return ( <> {sorted?.map(a => { if (a.kind === EventKind.TextNote) { let reactions = otherNotes?.notes?.filter(c => c.tags.find(b => b[0] === "e" && b[1] === a.id)); - return + return } 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); return }