mirror of
https://github.com/smolgrrr/TAO.git
synced 2024-09-20 01:11:25 +00:00
we up
This commit is contained in:
parent
aaacff5cb6
commit
8e6c396620
@ -5,6 +5,7 @@ import { Event } from 'nostr-tools';
|
||||
import { nip19 } from 'nostr-tools';
|
||||
import { getMetadata, uniqBy } from '../../utils/utils';
|
||||
import ContentPreview from '../Modals/TextModal';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
const colorCombos = [
|
||||
'from-red-400 to-yellow-500',
|
||||
@ -63,7 +64,7 @@ const ReplyCard = ({ event, metadata, replyCount, repliedTo }: { event: Event, m
|
||||
metadataParsed = getMetadata(metadata);
|
||||
}
|
||||
|
||||
// const replyPubkeys = event.tags.filter(tag => tag[0] === 'p');
|
||||
const replyPubkeys = event.tags.filter(tag => tag[0] === 'p');
|
||||
|
||||
// const getMetadataEvent = (event: Event) => {
|
||||
// const metadataEvent = uniqEvents.find(e => e.pubkey === event.pubkey && e.kind === 0);
|
||||
@ -72,6 +73,9 @@ const ReplyCard = ({ event, metadata, replyCount, repliedTo }: { event: Event, m
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
useEffect(() => {
|
||||
console.log(repliedTo)
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -100,9 +104,9 @@ const ReplyCard = ({ event, metadata, replyCount, repliedTo }: { event: Event, m
|
||||
</div>
|
||||
<div className="flex items-center my-1" >
|
||||
<span className="text-xs text-gray-500">Reply to: </span>
|
||||
{uniqBy(repliedTo, 'pubkey').map((event, index) => (
|
||||
{repliedTo.map((event, index) => (
|
||||
<>
|
||||
<img className={`h-5 w-5 rounded-full`} src={getMetadata(event).picture} />
|
||||
{/* <img className={`h-5 w-5 rounded-full`} src={getMetadata(event).picture} /> */}
|
||||
<div className={`h-5 w-5 bg-gradient-to-r ${getColorFromHash(event.pubkey, colorCombos)} rounded-full`} />
|
||||
</>
|
||||
))}
|
||||
|
@ -19,7 +19,6 @@ const Thread = () => {
|
||||
const { id } = useParams();
|
||||
const [events, setEvents] = useState<Event[]>([]); // Initialize state
|
||||
let decodeResult = nip19.decode(id as string);
|
||||
const [comment, setComment] = useState("");
|
||||
const [showForm, setShowForm] = useState(false);
|
||||
const [postType, setPostType] = useState("");
|
||||
|
||||
@ -41,28 +40,6 @@ const Thread = () => {
|
||||
};
|
||||
}, []); // Empty dependency array means this useEffect runs once when the component mounts
|
||||
|
||||
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
|
||||
event.preventDefault();
|
||||
let sk = generatePrivateKey();
|
||||
|
||||
try {
|
||||
const event = minePow({
|
||||
kind: 1,
|
||||
tags: [],
|
||||
content: comment,
|
||||
created_at: Math.floor(Date.now() / 1000),
|
||||
pubkey: getPublicKey(sk),
|
||||
}, difficulty);
|
||||
|
||||
const signedEvent = finishEvent(event, sk);
|
||||
await publish(signedEvent);
|
||||
console.log(signedEvent.id);
|
||||
|
||||
} catch (error) {
|
||||
setComment(comment + " " + error);
|
||||
}
|
||||
};
|
||||
|
||||
const uniqEvents = events.length > 0 ? uniqBy(events, "id") : [];
|
||||
|
||||
const getMetadataEvent = (event: Event) => {
|
||||
@ -78,7 +55,7 @@ const Thread = () => {
|
||||
}
|
||||
|
||||
const repliedList = (event: Event): Event[] => {
|
||||
return uniqEvents.filter(e => event.tags.some(tag => tag[0] === 'p' && tag[1] === e.pubkey) && e.kind === 0);
|
||||
return uniqEvents.filter(e => event.tags.some(tag => tag[0] === 'p' && tag[1] === e.pubkey));
|
||||
}
|
||||
|
||||
if (!uniqEvents[0]) {
|
||||
@ -127,7 +104,7 @@ const Thread = () => {
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<ThreadPost state={showForm} type={postType} />
|
||||
<ThreadPost OPEvent={uniqEvents[0]} state={showForm} type={postType} />
|
||||
</div>
|
||||
<div className="col-span-full h-0.5 bg-neutral-900"></div> {/* This is the white line separator */}
|
||||
{uniqEvents
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useState, useMemo, useEffect } from "react";
|
||||
import { ArrowUpTrayIcon, CpuChipIcon } from '@heroicons/react/24/outline';
|
||||
import { generatePrivateKey, getPublicKey, finishEvent } from 'nostr-tools';
|
||||
import { generatePrivateKey, getPublicKey, finishEvent, Event as NostrEvent } from 'nostr-tools';
|
||||
import { publish } from '../../utils/relays';
|
||||
import NostrImg from '../../utils/ImgUpload';
|
||||
import { nip19 } from 'nostr-tools';
|
||||
|
||||
|
||||
const ThreadPost = ({ state, type }: { state: Boolean, type: String }) => {
|
||||
const ThreadPost = ({ OPEvent, state, type }: { OPEvent: NostrEvent, state: Boolean, type: String }) => {
|
||||
const { id } = useParams();
|
||||
const [comment, setComment] = useState("");
|
||||
const [file, setFile] = useState("");
|
||||
@ -47,8 +47,10 @@ const ThreadPost = ({ state, type }: { state: Boolean, type: String }) => {
|
||||
let modifiedComment = comment + " " + file;
|
||||
if (type === 'r') {
|
||||
tags.push(["e", id as string])
|
||||
tags.push(["p", OPEvent.pubkey])
|
||||
} else if (type === 'q') {
|
||||
tags.push(["q", id as string])
|
||||
tags.push(["p", OPEvent.pubkey])
|
||||
modifiedComment += ' nostr:' + nip19.noteEncode(id);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user