import { useMemo } from 'react'; import { useSpotReports } from '@/hooks/useSpotReports'; import { useBatchSpotPhotos } from '@/hooks/useSpotContributions'; import { useBatchSpotStatus } from '@/hooks/useSpotStatus'; /** * A spot is auto-hidden pending human review when this many DISTINCT accounts * have reported it "not a skate spot" AND it has NO community signals at all * (no community photo, no status report). * * The "no community signals" clause is the anti-brigade guard: any real spot * that a skater has engaged with is left to a human instead. It is fully * reversible — a community photo/status (or an admin `cleared`/`verified` * verdict) brings it straight back. */ export const AUTO_HIDE_REPORT_THRESHOLD = 3; export function useAutoHiddenSpots( spots: Array<{ id: string; pubkey: string; identifier: string }>, ) { const reports = useSpotReports(spots); const photos = useBatchSpotPhotos(spots); const status = useBatchSpotStatus(spots); const autoHiddenIds = useMemo(() => { const set = new Set(); for (const s of spots) { if (reports.getCounts(s.id).reporters < AUTO_HIDE_REPORT_THRESHOLD) continue; const hasPhoto = photos.getCommunityPhotoCount(s.pubkey, s.identifier) > 0; const hasStatus = (status.getStatus(s.pubkey, s.identifier)?.reporterCount ?? 0) > 0; if (hasPhoto || hasStatus) continue; set.add(s.id); } return set; }, [spots, reports, photos, status]); return { autoHiddenIds, isAutoHidden: (id: string) => autoHiddenIds.has(id), }; }