@@ -89,6 +91,7 @@ const PostCard = ({ event}: { event: Event }) => {
)} */}
+
>
);
diff --git a/client/src/components/Thread/Thread.tsx b/client/src/components/Thread/Thread.tsx
index 3aa6c47..dcb9adc 100644
--- a/client/src/components/Thread/Thread.tsx
+++ b/client/src/components/Thread/Thread.tsx
@@ -1,13 +1,18 @@
import { useParams } from 'react-router-dom';
import { useState } from "react";
-import { Event } from "nostr-tools"
+import { Event, nip19 } from "nostr-tools"
import { subNote } from '../../utils/subscriptions';
import { useEffect } from 'react';
import PostCard from '../PostCard/PostCard';
+import { uniqBy } from '../../utils/utils';
+import OPPostCard from '../PostCard/OPPostCard';
+import { DocumentTextIcon, FolderPlusIcon } from '@heroicons/react/24/outline';
const Thread = () => {
const { id } = useParams();
const [events, setEvents] = useState
([]); // Initialize state
+ let decodeResult = nip19.decode(id as string);
+
// Define your callback function for subGlobalFeed
const onEvent = (event: Event, relay: string) => {
@@ -16,20 +21,54 @@ const Thread = () => {
};
useEffect(() => {
+ if (decodeResult.type === 'note') {
+ let id_to_hex: string = decodeResult.data;
+ // Call your subNote function or do whatever you need to do with id_to_hex
+ subNote(id_to_hex, onEvent);
+ }
// Subscribe to global feed when the component mounts
- subNote(id as string, onEvent);
-
// Optionally, return a cleanup function to unsubscribe when the component unmounts
return () => {
// Your cleanup code here
};
}, []); // Empty dependency array means this useEffect runs once when the component mounts
+ const uniqEvents = events.length > 0 ? uniqBy(events, "id") : [];
+
+ if (!uniqEvents[0]) {
+ return (
+
+
+
+ );
+ }
return (
<>
- {events.sort((a, b) => b.created_at - a.created_at).map((event, index) => (
+
+
+
+
+
+
{/* This is the white line separator */}
+ {uniqEvents.sort((a, b) => b.created_at - a.created_at).map((event, index) => (
))}