All files / app/features/celebration100k useMemberClusters.ts

100% Statements 7/7
100% Branches 0/0
100% Functions 2/2
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 211x   1x 1x     1x           53x 53x   5x          
import { useQuery } from "@tanstack/react-query";
 
import { CLUSTERED_MEMBERS_PATH } from "./constants";
import { clusterMembers, fetchMemberLocations } from "./mapData";
 
// Plain env read, so this doesn't pull in the full map library just for the URL
const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL;
 
/**
 * Member clusters for the map, shared between the autoplay preload and the overlay. Grouped inside the query
 * function so only the coarse clusters are cached (and persisted to storage), never individual member locations.
 */
export function useMemberClusters(enabled: boolean) {
  return useQuery({
    queryKey: ["celebration100kClusters"],
    queryFn: async () => clusterMembers(await fetchMemberLocations(`${API_BASE_URL}${CLUSTERED_MEMBERS_PATH}`)),
    enabled,
    staleTime: Infinity,
  });
}