feat: support rendering kind 20,21,22
feat: reply to non-text-note as kind 1111
This commit is contained in:
@ -139,7 +139,6 @@ export function NoteCreator() {
|
||||
extraTags ??= [];
|
||||
extraTags.push(["content-warning", note.sensitive]);
|
||||
}
|
||||
const kind = note.pollOptions ? EventKind.Polls : EventKind.TextNote;
|
||||
if (note.pollOptions) {
|
||||
extraTags ??= [];
|
||||
extraTags.push(...note.pollOptions.map((a, i) => ["poll_option", i.toString(), a]));
|
||||
@ -179,7 +178,9 @@ export function NoteCreator() {
|
||||
const hk = (eb: EventBuilder) => {
|
||||
extraTags?.forEach(t => eb.tag(t));
|
||||
note.extraTags?.forEach(t => eb.tag(t));
|
||||
eb.kind(kind);
|
||||
if (note.pollOptions) {
|
||||
eb.kind(EventKind.Polls);
|
||||
}
|
||||
return eb;
|
||||
};
|
||||
const ev = note.replyTo
|
||||
|
@ -1,6 +1,6 @@
|
||||
import "./EventComponent.css";
|
||||
|
||||
import { EventKind, NostrEvent, TaggedNostrEvent } from "@snort/system";
|
||||
import { EventKind, NostrEvent, parseIMeta, TaggedNostrEvent } from "@snort/system";
|
||||
import { memo, ReactNode } from "react";
|
||||
|
||||
import PubkeyList from "@/Components/Embed/PubkeyList";
|
||||
@ -75,6 +75,21 @@ export default memo(function EventComponent(props: NoteProps) {
|
||||
case 9041: // Assuming 9041 is a valid EventKind
|
||||
content = <ZapGoal ev={ev} />;
|
||||
break;
|
||||
case EventKind.Photo:
|
||||
case EventKind.Video:
|
||||
case EventKind.ShortVideo: {
|
||||
// append media to note as if kind1 post
|
||||
const media = parseIMeta(ev.tags);
|
||||
// Sometimes we cann call this twice so check the URL's are not already
|
||||
// in the content
|
||||
const urls = Object.entries(media ?? {}).map(([k]) => k);
|
||||
if (!urls.every(u => ev.content.includes(u))) {
|
||||
const newContent = ev.content + " " + urls.join("\n");
|
||||
props.data.content = newContent;
|
||||
}
|
||||
content = <Note {...props} />;
|
||||
break;
|
||||
}
|
||||
case EventKind.LongFormTextNote:
|
||||
content = (
|
||||
<LongFormText
|
||||
|
@ -32,7 +32,14 @@ const defaultOptions = {
|
||||
showContextMenu: true,
|
||||
};
|
||||
|
||||
const canRenderAsTextNote = [EventKind.TextNote, EventKind.Polls];
|
||||
const canRenderAsTextNote = [
|
||||
EventKind.TextNote,
|
||||
EventKind.Polls,
|
||||
EventKind.Photo,
|
||||
EventKind.Video,
|
||||
EventKind.ShortVideo,
|
||||
EventKind.Comment,
|
||||
];
|
||||
const translationCache = new LRUCache<string, NoteTranslation>({ maxSize: 300 });
|
||||
|
||||
export function Note(props: NoteProps) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { EventKind, Nip10, NostrLink, RequestBuilder } from "@snort/system";
|
||||
import { EventKind, Nip10, Nip22, NostrLink, RequestBuilder } from "@snort/system";
|
||||
import { SnortContext, useRequestBuilder } from "@snort/system-react";
|
||||
import { useContext, useEffect, useMemo, useState } from "react";
|
||||
|
||||
@ -34,7 +34,7 @@ export default function useThreadFeed(link: NostrLink) {
|
||||
for (const v of Object.values(grouped)) {
|
||||
sub
|
||||
.withFilter()
|
||||
.kinds([EventKind.TextNote])
|
||||
.kinds([EventKind.TextNote, EventKind.Comment])
|
||||
.replyToLink(v)
|
||||
.relay(rootRelays ?? []);
|
||||
}
|
||||
@ -48,7 +48,9 @@ export default function useThreadFeed(link: NostrLink) {
|
||||
const links = store
|
||||
.map(a => [
|
||||
NostrLink.fromEvent(a),
|
||||
...a.tags.filter(a => a[0] === "e" || a[0] === "a").map(v => NostrLink.fromTag(v)),
|
||||
...a.tags
|
||||
.filter(a => a[0] === "e" || a[0] === "a" || a[0] === "E" || a[0] === "A")
|
||||
.map(v => NostrLink.fromTag(v)),
|
||||
])
|
||||
.flat();
|
||||
setAllEvents(links);
|
||||
@ -56,14 +58,19 @@ export default function useThreadFeed(link: NostrLink) {
|
||||
// load the thread structure from the current note
|
||||
const current = store.find(a => link.matchesEvent(a));
|
||||
if (current) {
|
||||
const t = Nip10.parseThread(current);
|
||||
if (t) {
|
||||
const rootOrReplyAsRoot = t?.root ?? t?.replyTo;
|
||||
if (rootOrReplyAsRoot) {
|
||||
setRoot(rootOrReplyAsRoot);
|
||||
if (current.kind === EventKind.TextNote) {
|
||||
const t = Nip10.parseThread(current);
|
||||
if (t) {
|
||||
const rootOrReplyAsRoot = t?.root ?? t?.replyTo;
|
||||
if (rootOrReplyAsRoot) {
|
||||
setRoot(rootOrReplyAsRoot);
|
||||
}
|
||||
} else {
|
||||
setRoot(link);
|
||||
}
|
||||
} else {
|
||||
setRoot(link);
|
||||
const root = Nip22.rootScopeOf(current);
|
||||
setRoot(NostrLink.fromTag(root));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Nip10, NostrLink, TaggedNostrEvent } from "@snort/system";
|
||||
import { EventKind, Nip10, NostrLink, TaggedNostrEvent } from "@snort/system";
|
||||
|
||||
/**
|
||||
* Get the chain key as a reply event
|
||||
@ -6,9 +6,14 @@ import { Nip10, NostrLink, TaggedNostrEvent } from "@snort/system";
|
||||
* ie. Get the key for which this event is replying to
|
||||
*/
|
||||
export function replyChainKey(ev: TaggedNostrEvent) {
|
||||
const t = Nip10.parseThread(ev);
|
||||
const tag = t?.replyTo ?? t?.root;
|
||||
return tag?.tagKey;
|
||||
if (ev.kind !== EventKind.Comment) {
|
||||
const t = Nip10.parseThread(ev);
|
||||
const tag = t?.replyTo ?? t?.root;
|
||||
return tag?.tagKey;
|
||||
} else {
|
||||
const k = ev.tags.find(t => ["e", "a", "i"].includes(t[0]));
|
||||
return k?.[1];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user