feat: trending notes
This commit is contained in:
34
packages/app/src/Element/TrendingPosts.tsx
Normal file
34
packages/app/src/Element/TrendingPosts.tsx
Normal file
@ -0,0 +1,34 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { RawEvent, TaggedRawEvent } from "@snort/nostr";
|
||||
import { FormattedMessage } from "react-intl";
|
||||
|
||||
import PageSpinner from "Element/PageSpinner";
|
||||
import Note from "Element/Note";
|
||||
import NostrBandApi from "NostrBand";
|
||||
|
||||
export default function TrendingNotes() {
|
||||
const [posts, setPosts] = useState<Array<RawEvent>>();
|
||||
|
||||
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 (
|
||||
<>
|
||||
<h3>
|
||||
<FormattedMessage defaultMessage="Trending Notes" />
|
||||
</h3>
|
||||
{posts.map(e => (
|
||||
<Note key={e.id} data={e as TaggedRawEvent} related={[]} depth={0} />
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user