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

34 lines
871 B
TypeScript
Raw Normal View History

2023-04-18 10:40:56 +00:00
import { useEffect, useState } from "react";
import { HexKey } from "@snort/nostr";
import { FormattedMessage } from "react-intl";
import FollowListBase from "Element/FollowListBase";
import PageSpinner from "Element/PageSpinner";
2023-05-10 11:32:09 +00:00
import NostrBandApi from "NostrBand";
2023-04-18 10:40:56 +00:00
2023-05-10 11:32:09 +00:00
export default function TrendingUsers() {
const [userList, setUserList] = useState<HexKey[]>();
2023-04-18 10:40:56 +00:00
2023-05-10 11:32:09 +00:00
async function loadTrendingUsers() {
const api = new NostrBandApi();
const users = await api.trendingProfiles();
const keys = users.profiles.map(a => a.pubkey);
setUserList(keys);
2023-04-18 10:40:56 +00:00
}
useEffect(() => {
2023-05-10 11:32:09 +00:00
loadTrendingUsers().catch(console.error);
2023-04-18 10:40:56 +00:00
}, []);
if (!userList) return <PageSpinner />;
return (
<>
<h3>
2023-05-10 11:32:09 +00:00
<FormattedMessage defaultMessage="Trending People" />
2023-04-18 10:40:56 +00:00
</h3>
2023-04-18 10:42:12 +00:00
<FollowListBase pubkeys={userList} showAbout={true} />
2023-04-18 10:40:56 +00:00
</>
);
2023-05-10 11:32:09 +00:00
}