@@ -119,7 +69,7 @@ const Notifications = () => {
e.pubkey === event.pubkey && e.kind === 0) || null}
- replyCount={countReplies(event)}
+ replies={countReplies(event)}
/>
:
{
e.pubkey === event.pubkey && e.kind === 0) || null}
- replyCount={countReplies(event)}
+ replies={countReplies(event)}
/>
:
{
const [postType, setPostType] = useState("");
const [hasRun, setHasRun] = useState(false);
const [preOPEvents, setPreOPEvents] = useState(['']);
- const [sortByTime, setSortByTime] = useState(true);
- const filterDifficulty = useState(localStorage.getItem("filterDifficulty") || "20");
- // Load cached metadataEvents from localStorage
+ // const filterDifficulty = useState(localStorage.getItem("filterDifficulty") || "20");
+ // Load cached metadataEvents from localStorage
const [cachedMetadataEvents, setCachedMetadataEvents] = useState(
JSON.parse(localStorage.getItem("cachedMetadataEvents") || "[]")
);
@@ -96,7 +93,7 @@ const Thread = () => {
}, [uniqEvents, hasRun]);
const countReplies = (event: Event) => {
- return uniqEvents.filter(e => e.tags.some(tag => tag[0] === 'e' && tag[1] === event.id)).length;
+ return uniqEvents.filter(e => e.tags.some(tag => tag[0] === 'e' && tag[1] === event.id));
}
const repliedList = (event: Event): Event[] => {
@@ -109,34 +106,18 @@ const Thread = () => {
preOPEvents.includes(event.id)
).sort((a, b) => (b.created_at as any) - (a.created_at as any));
- const toggleSort = () => {
- setSortByTime(prev => !prev);
- };
-
- const eventsSortedByTime = [...uniqEvents].slice(1)
+ const displayedEvents = [...uniqEvents].slice(1)
.filter(event =>
event.kind === 1 &&
!earlierEvents.map(e => e.id).includes(event.id) &&
(OPEvent ? OPEvent.id !== event.id : true)
).sort((a, b) => a.created_at - b.created_at);
- // Events sorted by PoW (assuming `getPow` returns a numerical representation of the PoW)
- const eventsSortedByPow = [...uniqEvents].slice(1)
- .filter((event) =>
- getPow(event.id) > Number(filterDifficulty) &&
- event.kind === 1 &&
- !earlierEvents.map(e => e.id).includes(event.id) &&
- (OPEvent ? OPEvent.id !== event.id : true)
- ).sort((a, b) => getPow(b.id) - getPow(a.id));
-
- const displayedEvents = sortByTime ? eventsSortedByTime : eventsSortedByPow;
-
if (uniqEvents.length === 0) {
return (
<>
{/* This is the white line separator */}
-
>
);
}
@@ -147,9 +128,9 @@ const Thread = () => {
{earlierEvents
.filter(event => event.kind === 1)
.sort((a, b) => a.created_at - b.created_at).map((event, index) => (
- e.pubkey === event.pubkey && e.kind === 0) || null} replyCount={countReplies(event)} />
+ e.pubkey === event.pubkey && e.kind === 0) || null} replies={countReplies(event)} />
))}
- {OPEvent && e.pubkey === OPEvent.pubkey && e.kind === 0) || null} replyCount={countReplies(OPEvent)} type={'OP'}/>}
+ {OPEvent && e.pubkey === OPEvent.pubkey && e.kind === 0) || null} replies={countReplies(OPEvent)} type={'OP'}/>}