fix: top zappers

This commit is contained in:
Alejandro Gomez
2023-06-26 15:28:06 +02:00
parent aa66e678d1
commit 8bc4c1e2ce

View File

@ -42,13 +42,12 @@ function totalZapped(pubkey: string, zaps: ParsedZap[]) {
function TopZappers({ zaps }: { zaps: ParsedZap[] }) { function TopZappers({ zaps }: { zaps: ParsedZap[] }) {
const zappers = zaps const zappers = zaps
.map((z) => (z.anonZap ? "anon" : z.sender)) .map((z) => (z.anonZap ? "anon" : z.sender))
.map((p) => p as string) .map((p) => p as string);
.slice(0, 3);
const sortedZappers = useMemo(() => { const sortedZappers = useMemo(() => {
const sorted = [...new Set([...zappers])]; const sorted = [...new Set([...zappers])];
sorted.sort((a, b) => totalZapped(b, zaps) - totalZapped(a, zaps)); sorted.sort((a, b) => totalZapped(b, zaps) - totalZapped(a, zaps));
return sorted; return sorted.slice(0, 3);
}, [zaps, zappers]); }, [zaps, zappers]);
return ( return (