diff --git a/src/element/NoteFooter.js b/src/element/NoteFooter.js index 775d62b9..1b2794bc 100644 --- a/src/element/NoteFooter.js +++ b/src/element/NoteFooter.js @@ -1,6 +1,6 @@ import { useMemo, useState } from "react"; import { useSelector } from "react-redux"; -import { faHeart, faReply, faThumbsDown, faTrash, faBolt } from "@fortawesome/free-solid-svg-icons"; +import { faHeart, faReply, faThumbsDown, faTrash, faBolt, faRepeat } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import useEventPublisher from "../feed/EventPublisher"; @@ -46,6 +46,11 @@ export default function NoteFooter(props) { } } + async function repost() { + let evRepost = await publisher.repost(ev); + publisher.broadcast(evRepost); + } + function tipButton() { let service = author?.lud16 || author?.lud06; if (service) { @@ -79,6 +84,9 @@ export default function NoteFooter(props) { deleteEvent()} /> : null} {tipButton()} + repost()}> + + setReply(s => !s)}> diff --git a/src/feed/EventPublisher.js b/src/feed/EventPublisher.js index d4809b83..f1f08ef3 100644 --- a/src/feed/EventPublisher.js +++ b/src/feed/EventPublisher.js @@ -64,15 +64,13 @@ export default function useEventPublisher() { let thread = replyTo.Thread; if (thread) { + console.debug(replyTo); if (thread.Root) { ev.Tags.push(new Tag(["e", thread.Root.Event, "", "root"], ev.Tags.length)); } else { - let unRootedReply = thread.Reply.Thread; - ev.Tags.push(new Tag(["e", unRootedReply.ReplyTo.Event, "", "root"], ev.Tags.length)); - } - if (thread.Reply) { - ev.Tags.push(new Tag(["e", thread.Reply.Id, "", "reply"], ev.Tags.length)); + ev.Tags.push(new Tag(["e", thread.ReplyTo.Event, "", "root"], ev.Tags.length)); } + ev.Tags.push(new Tag(["e", replyTo.Id, "", "reply"], ev.Tags.length)); ev.Tags.push(new Tag(["p", replyTo.PubKey], ev.Tags.length)); for (let pk of thread.PubKeys) { ev.Tags.push(new Tag(["p", pk], ev.Tags.length)); @@ -121,6 +119,17 @@ export default function useEventPublisher() { ev.Content = ""; ev.Tags.push(new Tag(["e", id])); return await signEvent(ev); + }, + repost: async (note) => { + if (typeof note.Id !== "string") { + throw "Must be parsed note in Event class"; + } + let ev = Event.ForPubKey(pubKey); + ev.Kind = EventKind.Repost; + ev.Content = ""; + ev.Tags.push(new Tag(["e", note.Id])); + ev.Tags.push(new Tag(["p", note.PubKey])); + return await signEvent(ev); } } } \ No newline at end of file diff --git a/src/index.css b/src/index.css index 3bd5bd0d..89629743 100644 --- a/src/index.css +++ b/src/index.css @@ -65,6 +65,10 @@ code { border-radius: 25px; } +textarea { + font: inherit; +} + input[type="text"], input[type="password"], input[type="number"], textarea { padding: 10px; border-radius: 5px; diff --git a/src/nostr/EventKind.js b/src/nostr/EventKind.js index e6acbd6e..42347886 100644 --- a/src/nostr/EventKind.js +++ b/src/nostr/EventKind.js @@ -5,7 +5,8 @@ const EventKind = { RecommendServer: 2, ContactList: 3, // NIP-02 DirectMessage: 4, // NIP-04 - Deletion: 5, + Deletion: 5, // NIP-09 + Repost: 6, // NIP-18 Reaction: 7 // NIP-25 }; diff --git a/src/nostr/Tag.js b/src/nostr/Tag.js index 0569c86c..d27554c2 100644 --- a/src/nostr/Tag.js +++ b/src/nostr/Tag.js @@ -42,7 +42,7 @@ export default class Tag { ToObject() { switch (this.Key) { case "e": { - return ["e", this.Event, this.Relay, this.Marker].filter(a => a !== null); + return ["e", this.Event, this.Relay, this.Marker]; } case "p": { return ["p", this.PubKey]; diff --git a/src/nostr/Thread.js b/src/nostr/Thread.js index 75b9dd68..bec5a5f1 100644 --- a/src/nostr/Thread.js +++ b/src/nostr/Thread.js @@ -8,8 +8,6 @@ export default class Thread { this.ReplyTo = null; /** @type {Array} */ this.Mentions = []; - /** @type {Event} */ - this.Reply = null; /** @type {Array} */ this.PubKeys = []; } @@ -25,7 +23,6 @@ export default class Thread { } let ret = new Thread(); - ret.Reply = ev; let eTags = ev.Tags.filter(a => a.Key === "e"); let marked = eTags.some(a => a.Marker !== null); if (!marked) {