filter nostr notes better

This commit is contained in:
Paul Miller
2023-04-05 12:04:28 -05:00
parent 4d08cb292c
commit 3f2104968c

View File

@@ -34,9 +34,19 @@ const Note: Component<{ e: NostrEvent }> = (props) => {
)
}
function filterReplies(event: Event) {
// If there's a "p" tag or an "e" tag we want to return false, otherwise true
for (const tag of event.tags) {
if (tag[0] === "p" || tag[0] === "e") {
return false
}
}
return true
}
const Notes: Component<{ notes: Event[] }> = (props) => {
return (<ul class="flex flex-col">
<For each={props.notes.filter((event) => !event.tags.length).sort((a, b) => b.created_at - a.created_at)}>
<For each={props.notes.filter(filterReplies).sort((a, b) => b.created_at - a.created_at)}>
{(item) =>
<li class="w-full"><Note e={item as NostrEvent} /></li>
}