import { useQuery } from '@tanstack/react-query'; import { VList } from 'virtua'; import { LoaderIcon } from '@shared/icons'; import { TitleBar } from '@shared/titleBar'; import { WidgetWrapper } from '@shared/widgets'; import { NostrBandUserProfile, type Profile } from '@shared/widgets/nostrBandUserProfile'; import { Widget } from '@utils/types'; interface Response { profiles: Array<{ pubkey: string }>; } export function TrendingAccountsWidget({ params }: { params: Widget }) { const { status, data } = useQuery({ queryKey: ['trending-profiles-widget'], queryFn: async () => { const res = await fetch('https://api.nostr.band/v0/trending/profiles'); if (!res.ok) { throw new Error('Error'); } const json: Response = await res.json(); if (!json.profiles) return []; return json.profiles; }, refetchOnMount: false, refetchOnReconnect: false, refetchOnWindowFocus: false, staleTime: Infinity, }); return (
{status === 'pending' ? (

Loading trending accounts...

) : status === 'error' ? (
empty feeds

Sorry, an unexpected error has occurred.

) : ( {data.map((item: Profile) => ( ))}
)}
); }