snort/packages/app/src/Element/TrendingPosts.tsx

31 lines
777 B
TypeScript
Raw Normal View History

2023-05-10 11:32:09 +00:00
import { useEffect, useState } from "react";
2023-08-17 18:54:14 +00:00
import { NostrEvent, TaggedNostrEvent } from "@snort/system";
2023-05-10 11:32:09 +00:00
import PageSpinner from "Element/PageSpinner";
import Note from "Element/Note";
2023-05-15 08:51:17 +00:00
import NostrBandApi from "External/NostrBand";
2023-05-10 11:32:09 +00:00
export default function TrendingNotes() {
const [posts, setPosts] = useState<Array<NostrEvent>>();
2023-05-10 11:32:09 +00:00
async function loadTrendingNotes() {
const api = new NostrBandApi();
const trending = await api.trendingNotes();
setPosts(trending.notes.map(a => a.event));
}
useEffect(() => {
loadTrendingNotes().catch(console.error);
}, []);
if (!posts) return <PageSpinner />;
return (
<>
{posts.map(e => (
2023-08-17 18:54:14 +00:00
<Note key={e.id} data={e as TaggedNostrEvent} related={[]} depth={0} />
2023-05-10 11:32:09 +00:00
))}
</>
);
}