import { UsersIcon } from "@heroicons/react/24/outline"; import { type FollowersYouKnowRequest, useFollowersYouKnowQuery } from "@hey/indexer"; import { motion } from "motion/react"; import { useCallback } from "react"; import { Virtualizer } from "virtua"; import SingleAccount from "@/components/Shared/Account/SingleAccount"; import AccountListShimmer from "@/components/Shared/Shimmer/AccountListShimmer"; import { EmptyState, ErrorMessage } from "@/components/Shared/UI"; import cn from "@/helpers/cn"; import useLoadMoreOnIntersect from "@/hooks/useLoadMoreOnIntersect"; import { useAccountStore } from "@/store/persisted/useAccountStore"; import { accountsList } from "@/variants"; interface FollowersYouKnowProps { username: string; address: string; } const FollowersYouKnow = ({ username, address }: FollowersYouKnowProps) => { const { currentAccount } = useAccountStore(); const request: FollowersYouKnowRequest = { observer: currentAccount?.address, target: address }; const { data, error, fetchMore, loading } = useFollowersYouKnowQuery({ skip: !address, variables: { request } }); const followersYouKnow = data?.followersYouKnow?.items; const pageInfo = data?.followersYouKnow?.pageInfo; const hasMore = pageInfo?.next; const handleEndReached = useCallback(async () => { if (hasMore) { await fetchMore({ variables: { request: { ...request, cursor: pageInfo?.next } } }); } }, [fetchMore, hasMore, pageInfo?.next, request]); const loadMoreRef = useLoadMoreOnIntersect(handleEndReached); if (loading) { return ; } if (!followersYouKnow?.length) { return ( } message={
{username} doesn't have any mutual followers.
} /> ); } if (error) { return ( ); } return (
{followersYouKnow.map((follower, index) => ( ))} {hasMore && }
); }; export default FollowersYouKnow;