forked from Kieran/snort
Repost init
This commit is contained in:
parent
bfc25f6ce1
commit
c01e0ca457
@ -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) {
|
||||
<FontAwesomeIcon icon={faTrash} onClick={(e) => deleteEvent()} />
|
||||
</span> : null}
|
||||
{tipButton()}
|
||||
<span className="pill" onClick={() => repost()}>
|
||||
<FontAwesomeIcon icon={faRepeat} />
|
||||
</span>
|
||||
<span className="pill" onClick={(e) => setReply(s => !s)}>
|
||||
<FontAwesomeIcon icon={faReply} />
|
||||
</span>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
@ -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];
|
||||
|
@ -8,8 +8,6 @@ export default class Thread {
|
||||
this.ReplyTo = null;
|
||||
/** @type {Array<Tag>} */
|
||||
this.Mentions = [];
|
||||
/** @type {Event} */
|
||||
this.Reply = null;
|
||||
/** @type {Array<String>} */
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user