fix: preserve tag info in notification context
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
839f448231
commit
eba47f085d
@ -11,7 +11,7 @@ import { Bar, BarChart, Tooltip, XAxis, YAxis } from "recharts";
|
|||||||
import useLogin from "Hooks/useLogin";
|
import useLogin from "Hooks/useLogin";
|
||||||
import { markNotificationsRead } from "Login";
|
import { markNotificationsRead } from "Login";
|
||||||
import { Notifications } from "Cache";
|
import { Notifications } from "Cache";
|
||||||
import { dedupe, findTag, orderAscending, orderDescending, getDisplayName } from "SnortUtils";
|
import { dedupe, orderAscending, orderDescending, getDisplayName } from "SnortUtils";
|
||||||
import Icon from "Icons/Icon";
|
import Icon from "Icons/Icon";
|
||||||
import ProfileImage from "Element/User/ProfileImage";
|
import ProfileImage from "Element/User/ProfileImage";
|
||||||
import useModeration from "Hooks/useModeration";
|
import useModeration from "Hooks/useModeration";
|
||||||
@ -28,18 +28,17 @@ import { ShowMoreInView } from "Element/Event/ShowMore";
|
|||||||
function notificationContext(ev: TaggedNostrEvent) {
|
function notificationContext(ev: TaggedNostrEvent) {
|
||||||
switch (ev.kind) {
|
switch (ev.kind) {
|
||||||
case EventKind.ZapReceipt: {
|
case EventKind.ZapReceipt: {
|
||||||
const aTag = findTag(ev, "a");
|
const aTag = ev.tags.find(a => a[0] === "a");
|
||||||
if (aTag) {
|
if (aTag) {
|
||||||
const [kind, author, d] = aTag.split(":");
|
return NostrLink.fromTag(aTag);
|
||||||
return new NostrLink(NostrPrefix.Address, d, Number(kind), author);
|
|
||||||
}
|
}
|
||||||
const eTag = findTag(ev, "e");
|
const eTag = ev.tags.find(a => a[0] === "e");
|
||||||
if (eTag) {
|
if (eTag) {
|
||||||
return new NostrLink(CONFIG.eventLinkPrefix, eTag);
|
return NostrLink.fromTag(eTag);
|
||||||
}
|
}
|
||||||
const pTag = ev.tags.filter(a => a[0] === "p").slice(-1)?.[0];
|
const pTag = ev.tags.find(a => a[0] === "p");
|
||||||
if (pTag) {
|
if (pTag) {
|
||||||
return new NostrLink(NostrPrefix.PublicKey, pTag[1]);
|
return NostrLink.fromTag(pTag);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -47,17 +46,14 @@ function notificationContext(ev: TaggedNostrEvent) {
|
|||||||
case EventKind.Reaction: {
|
case EventKind.Reaction: {
|
||||||
const thread = EventExt.extractThread(ev);
|
const thread = EventExt.extractThread(ev);
|
||||||
const tag = unwrap(thread?.replyTo ?? thread?.root ?? { value: ev.id, key: "e" });
|
const tag = unwrap(thread?.replyTo ?? thread?.root ?? { value: ev.id, key: "e" });
|
||||||
if (tag.key === "e") {
|
if (tag.key === "e" || tag.key === "a") {
|
||||||
return new NostrLink(CONFIG.eventLinkPrefix, unwrap(tag.value));
|
return NostrLink.fromThreadTag(tag);
|
||||||
} else if (tag.key === "a") {
|
|
||||||
const [kind, author, d] = unwrap(tag.value).split(":");
|
|
||||||
return new NostrLink(NostrPrefix.Address, d, Number(kind), author);
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Unknown thread context");
|
throw new Error("Unknown thread context");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case EventKind.TextNote: {
|
case EventKind.TextNote: {
|
||||||
return new NostrLink(NostrPrefix.Note, ev.id);
|
return NostrLink.fromEvent(ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user