"use client";
import { useEffect } from "react";
import { usePathname } from "next/navigation";
import { useSelection } from "./SelectionProvider";

export function RegisterVisible({ ids }: { ids: number[] }) {
  const pathname = usePathname();
  const { clear, setVisibleIds } = useSelection();

  useEffect(() => {
    setVisibleIds(ids);
    return () => setVisibleIds([]);
  }, [ids, setVisibleIds]);

  useEffect(() => {
    return () => clear();
  }, [pathname, clear]);

  return null;
}
